var nd = nd || {};
nd.allActivity = nd.allActivity || {}, nd.allActivity.SHOW_NEARBY_CONTENT = 0, nd.allActivity.FILTER_NEARBY_CONTENT = 1, nd.allActivity.NEARBY_FILTER_STATE_ID = 3, nd.allActivity.HIDE_ALERT = 0, nd.allActivity.HOME_NN_ALERT_STATE_ID = 4, nd.allActivity.HOME_NN_REMOVED_STATE_ID = 5, nd.allActivity.initialize = function () {
    $("[data-toggle=nearby-content-filter]").on("click", function () {
        var state;
        state = "nearby-on" == $(this).data("value") ? nd.allActivity.SHOW_NEARBY_CONTENT : nd.allActivity.FILTER_NEARBY_CONTENT, $.ajax("/ajax/update_userprofile_state/", {
            type: "POST",
            data: {
                state_id: nd.allActivity.NEARBY_FILTER_STATE_ID,
                state_value: state
            },
            dataType: "json",
            success: function (data) {
                data.success ? location.reload(!0) : nd.allActivity.nearbyContentFilterErrorCallback(data)
            },
            error: function (data) {
                nd.allActivity.nearbyContentFilterErrorCallback(data)
            }
        })
    }), $(document).on("click", '[data-dismiss="popover"]', function () {
        $('[data-toggle="all-activity-settings"]').popover("hide")
    }), $("#invite_prompt_simple_close").on("click", function () {
        $("#invite_prompt_simple").slideUp(), $.post("/ajax_nf_hide_invite_prompt/", {
            display: 0
        })
    }), $('#invite_prompt_checklist [data-toggle="checklist-content"]').on("click", function () {
        $("#checklist_content").data("state");
        var toggle_behavior = $(this).data("toggle-state");
        "checklist-content-hide" == toggle_behavior && ($("#checklist_content").hide(), $('[data-toggle-state="checklist-content-hide"]').hide(), $('[data-toggle-state="checklist-content-show"]').show(), $.post("/ajax_nf_hide_invite_prompt/", {
            display: 0
        })), "checklist-content-show" == toggle_behavior && ($("#checklist_content").show(), $('[data-toggle-state="checklist-content-hide"]').show(), $('[data-toggle-state="checklist-content-show"]').hide(), $.post("/ajax_nf_show_invite_prompt/", {
            display: 1
        })), "checklist-content-close" == toggle_behavior && $("#invite_prompt_checklist").hide()
    }), $("#nf_invite_banner_close").on("click", function () {
        $("#nf_invite_banner").slideUp(), $.post("/ajax_nf_invite_banner/", {
            display: 0
        })
    }), $("#nf_invite_banner_ipad_close").on("click", function () {
        $("#nf_invite_banner_ipad").slideUp(), $.post("/ajax_nf_invite_banner/", {
            display: 0,
            ipad: 1
        })
    }), $("#dismiss_nn_filter_alert").click(function () {
        $.ajax("/ajax/update_userprofile_state/", {
            type: "POST",
            data: {
                state_id: nd.allActivity.HOME_NN_ALERT_STATE_ID,
                state_value: nd.allActivity.HIDE_ALERT
            },
            dataType: "json",
            success: function (data) {
                data.success ? $("#nn_filter_alert").slideUp() : nd.allActivity.hideNearbyAlertErrorCallback(data)
            },
            error: function (data) {
                nd.allActivity.hideNearbyAlertErrorCallback(data)
            }
        })
    }), $("#dismiss_nn_removed_alert").click(function () {
        $.ajax("/ajax/update_userprofile_state/", {
            type: "POST",
            data: {
                state_id: nd.allActivity.HOME_NN_REMOVED_STATE_ID,
                state_value: nd.allActivity.HIDE_ALERT
            },
            dataType: "json",
            success: function (data) {
                data.success ? $("#nn_removed_alert").slideUp() : nd.allActivity.hideNearbyRemovedAlertErrorCallback(data)
            },
            error: function (data) {
                nd.allActivity.hideNearbyRemovedAlertErrorCallback(data)
            }
        })
    })
}, nd.allActivity.nearbyContentFilterErrorCallback = function () {
    $("#ui_confirmation_text").html($("#nearby_content_filter_fail").html()).parent().slideDown()
}, nd.allActivity.hideNearbyAlertErrorCallback = function () {
    $("#nn_filter_alert").slideUp()
}, nd.allActivity.hideNearbyRemovedAlertErrorCallback = function () {
    $("#nn_removed_alert").slideUp()
};
var nd = nd || {};
nd.urgentAlert = nd.urgentAlert || {};
var modalTimeout = 5e3;
nd.urgentAlert.initUrgentAlert = function (listView) {
    function alertCanSubmit() {
        if ($("#submit_alert_button").data("city") && !$("#city_broadcast_recipients_emergency").val()) return !1;
        var alertContentField = $("#alert_content_field");
        return maxTextLength >= alertContentField.val().length && alertContentField.val() != alertContentField.attr("placeholder") && 0 != $.trim(alertContentField.val()).length
    }
    var maxTextLength = 110;
    $('[data-class="alert-char-limit"]').text(maxTextLength), $("#alert_state_1_tip_text").removeClass("error"), $("#alert_content_field").bind("change keyup", function () {
        numChar = $("#alert_content_field").val().length, $("#num_alert_char").text(numChar), numChar > maxTextLength ? ($("#alert_char_count").addClass("error"), $("#alert_state_1_tip_text").addClass("error")) : ($("#alert_char_count").removeClass("error"), $("#alert_state_1_tip_text").removeClass("error")), alertCanSubmit() ? ($("#review_alert_button").addClass("btn-primary"), $("#review_alert_button").removeClass("disabled")) : ($("#review_alert_button").removeClass("btn-primary"), $("#review_alert_button").addClass("disabled"))
    }), $("#review_alert_button").click(function () {
        if (alertCanSubmit() && ($('[data-class="alert-states"]').toggle(), $("#alert_char_count").hide(), $("#review_alert_button").hide(), $("#submit_alert_button").show(), $("#reset_alert_modal").show(), $("#alert_message_repeat").text($("#alert_content_field").val()), $("#submit_alert_button").data("city"))) {
            var hoodCount = nd.urgentAlert.getNumHoods(),
                hoodGroupCount = nd.urgentAlert.getNumHoodGroups();
            hoodGroupCount > 0 ? $("#hood_count_section").hide() : $("#hood_count_section").show(), $("#urgent_alerts_hood_count").pluralize(hoodCount), $("#urgent_alerts_tooltip").attr("data-original-title", nd.urgentAlert.toolTipString())
        }
    }), $("#reset_alert_modal").click(function () {
        $("#alert_char_count").show(), $('[data-class="alert-states"]').toggle(), $("#alert_message_repeat").text(""), $("#num_alert_char").text("0"), $('[data-class="init-hide"]').hide(), $('[data-class="init-show"]').show()
    }), $("#submit_alert_button").one("click", function submitAlertCallback() {
        var jsonData = {
            message: $.trim($("#alert_content_field").val()),
            list_view: listView
        };
        $("#submit_alert_button").data("city") && (jsonData.neighborhood_ids = $("#city_broadcast_recipients_emergency").select2("val")), nd.postBox.postBoxCollapse(), $("#modal_alert_spinner").show(), $.ajax({
            type: "POST",
            url: "/ajax/submit_alert/",
            dataType: "json",
            data: jsonData,
            success: function (data) {
                if (data.error) $("#modal_alert_spinner").hide();
                else if (data.story_id) {
                    $("#emergency_alert_modal").modal("hide");
                    var storyHtml = $(data.html);
                    $("#nf_stories").prepend(storyHtml), $("#s_" + data.story_id).hide(), $("#s_" + data.story_id).fadeIn("slow"), nd.feed.initFeedHandlers()
                }
                $("#submit_alert_button").one("click", submitAlertCallback)
            },
            error: function () {
                $("#modal_alert_spinner").hide(), $("#alert_submit_fail").show(), $("#submit_alert_button").one("click", submitAlertCallback)
            }
        })
    }), $("#emergency_alert_modal").on("shown", function () {
        if ($('[data-class="alert-states"]').hide(), $('[data-state="alert-state-1"]').show(), $("#city_broadcast_recipients_emergency")) {
            var city_placeholder_text = $("#city_broadcast_recipients_emergency").attr("placeholder");
            $("#city_broadcast_recipients_emergency").select2({
                placeholder: city_placeholder_text,
                containerCssClass: "input-block-level"
            })
        }
        $("#alert_content_field").val("").placeholder(), $("#alert_message_repeat").text(""), $("#num_alert_char").text("0"), $("#review_alert_button").removeClass("btn-primary"), $('[data-class="init-hide"]').hide(), $('[data-class="init-show"]').show(), $("#alert_state_1_tip_text").removeClass("error")
    })
}, nd.urgentAlert.editPostFilter = function (sender) {
    if (blockSMSSender) var successCallback = nd.urgentAlert.blockSenderSuccess;
    else var successCallback = nd.urgentAlert.unblockSenderSuccess;
    $.ajax({
        type: "POST",
        url: "/ajax/edit_post_filter/",
        data: {
            sender: sender,
            post_type: "sms",
            block: blockSMSSender
        },
        dataType: "json",
        success: successCallback,
        error: nd.urgentAlert.smsSenderError
    })
}, nd.urgentAlert.toolTipString = function () {
    var hoodIds = $("#city_broadcast_recipients_emergency").select2("val"),
        hoodNames = [];
    if ("" == "" + hoodIds) return "This alert will be sent to all neighborhoods.";
    for (var i = 0; hoodIds.length > i; i++) {
        var hoodName = $('#city_broadcast_recipients_emergency option[value="' + hoodIds[i] + '"]').html();
        hoodNames.push(hoodName)
    }
    return "This alert will be sent to " + hoodNames.join(", ") + "."
}, nd.urgentAlert.getNumHoods = function () {
    for (var hoodIds = $("#city_broadcast_recipients_emergency").select2("val"), totalHoodCount = 0, allOptions = $("#city_broadcast_recipients_emergency option"), i = 0; allOptions.length > i; i++) {
        var hoodId = allOptions[i]; - 1 == hoodId.value.indexOf("hood_group_") && "" != hoodId.value && totalHoodCount++
    }
    if ("" == "" + hoodIds) return totalHoodCount;
    for (var selectedHoodCount = 0, i = 0; hoodIds.length > i; i++) {
        var hoodId = hoodIds[i]; - 1 == hoodId.indexOf("hood_group_") && selectedHoodCount++
    }
    return selectedHoodCount
}, nd.urgentAlert.getNumHoodGroups = function () {
    var hoodIds = $("#city_broadcast_recipients_emergency").select2("val");
    if ("" == "" + hoodIds) return 0;
    for (var hoodGroupCount = 0, i = 0; hoodIds.length > i; i++) hoodId = hoodIds[i], 0 == hoodId.indexOf("hood_group_") && hoodGroupCount++;
    return hoodGroupCount
}, nd.urgentAlert.initBlockSMSModal = function () {
    $("#sms_sender_modal").modal("show"), $('[data-type="sms-block-start"]').show(), $("#cancel_sms_action").click(nd.urgentAlert.blockSenderCancel), blockSMSSender = !0
}, nd.urgentAlert.initUnblockSMSModal = function () {
    $("#sms_sender_modal").modal("show"), $('[data-type="sms-unblock-start"]').show(), $("#cancel_sms_action").click(nd.urgentAlert.unblockSenderCancel), blockSMSSender = !1
}, nd.urgentAlert.swapCloseButton = function () {
    $("#submit_sms_action").hide(), $("#cancel_sms_action").hide(), $("#close_sms_action").show()
}, nd.urgentAlert.blockSenderSuccess = function (data) {
    data.error ? nd.urgentAlert.smsSenderError() : ($('[data-class="sms-states"]').hide(), $('[data-type="sms-block-confirm"]').show(), nd.urgentAlert.swapCloseButton(), setTimeout(function () {
        $("#sms_sender_modal").modal("hide")
    }, modalTimeout))
}, nd.urgentAlert.unblockSenderSuccess = function (data) {
    data.error ? nd.urgentAlert.smsSenderError() : ($('[data-class="sms-states"]').hide(), $('[data-type="sms-unblock-confirm"]').show(), nd.urgentAlert.swapCloseButton(), setTimeout(function () {
        $("#sms_sender_modal").modal("hide")
    }, modalTimeout))
}, nd.urgentAlert.smsSenderError = function () {
    $('[data-class="sms-states"]').hide(), $('[data-type="sms-error"]').show(), nd.urgentAlert.swapCloseButton(), setTimeout(function () {
        $("#sms_sender_modal").modal("hide")
    }, modalTimeout)
}, nd.urgentAlert.blockSenderCancel = function () {
    $('[data-class="sms-states"]').hide(), $('[data-type="sms-block-cancel"]').show(), nd.urgentAlert.swapCloseButton(), setTimeout(function () {
        $("#sms_sender_modal").modal("hide")
    }, modalTimeout)
}, nd.urgentAlert.unblockSenderCancel = function () {
    $('[data-class="sms-states"]').hide(), $('[data-type="sms-unblock-cancel"]').show(), nd.urgentAlert.swapCloseButton(), setTimeout(function () {
        $("#sms_sender_modal").modal("hide")
    }, modalTimeout)
};
var nd = nd || {};
nd.facebookUtils = nd.facebookUtils || {}, nd.facebookUtils.facebookStatus, nd.facebookUtils.facebookAuth, nd.facebookUtils.fbPerms = "email,user_location,friends_location", nd.facebookUtils.gLoginCallback = function () {}, nd.facebookUtils.facebookInit = function (facebookAppId, asyncInitFunction, loginCallback, noWait) {
    loginCallback && (nd.facebookUtils.gLoginCallback = loginCallback);
    var f = document.createElement("div");
    f.id = "fb-root", $("body")[0].appendChild(f);
    var e = document.createElement("script");
    e.type = "text/javascript", e.src = document.location.protocol + "//connect.facebook.net/en_US/all.js", e.async = !0, $("head")[0].appendChild(e), $("#facebook_login_button").click(nd.facebookUtils.fbLogin), window.fbAsyncInit = asyncInitFunction ? asyncInitFunction : function () {
        FB.init({
            appId: facebookAppId,
            status: !0,
            cookie: !0,
            xfbml: !0
        }), FB.Event.subscribe("auth.login", function (response) {
            nd.facebookUtils.facebookStatus = response.status, nd.facebookUtils.facebookAuth = response.authResponse
        }), FB.Event.subscribe("auth.logout", function (response) {
            nd.facebookUtils.facebookStatus = response.status
        }), FB.getLoginStatus(function (response) {
            nd.facebookUtils.facebookStatus = response.status, nd.facebookUtils.facebookAuth = response.authResponse;
            var oldId = $("#existing_fbook_id").val();
            response.authResponse && oldId && oldId != response.authResponse.userID ? nd.facebookUtils.facebookStatus = null : noWait && nd.facebookUtils.gLoginCallback()
        })
    }
}, nd.facebookUtils.fbLogin = function () {
    "connected" == nd.facebookUtils.facebookStatus ? nd.facebookUtils.gLoginCallback() : FB.login(function (response) {
        nd.facebookUtils.facebookStatus = response.status, nd.facebookUtils.facebookAuth = response.authResponse, nd.facebookUtils.trackLoginAttempt(nd.facebookUtils.facebookStatus), nd.facebookUtils.gLoginCallback()
    }, {
        scope: nd.facebookUtils.fbPerms
    })
}, nd.facebookUtils.ndConnect = function () {
    if ("connected" == nd.facebookUtils.facebookStatus) {
        $(".fb_login_spinner").show(), $("#facebook_login_button").hide();
        var postArgs = {
            access_token: nd.facebookUtils.facebookAuth.accessToken,
            expires_in: nd.facebookUtils.facebookAuth.expiresIn,
            source: "facebook",
            signed_request: nd.facebookUtils.facebookAuth.signedRequest
        }, params = "?prev=" + window.location.pathname,
            resId = $("input[name=r]").val() || "";
        resId && (params += "&r=" + resId);
        var nextParam = $("input[name=next]").val() || "";
        nextParam && (nextParam = "&next=" + nextParam);
        var prefilledEmail = $("input[name=e]").val() || "";
        prefilledEmail && (params += "&e=" + prefilledEmail);
        var flow = $("input[name=f]").val() || "";
        flow && (params += "&f=" + flow), $.ajax({
            type: "POST",
            url: "/ajax/facebook_auth/" + params + nextParam,
            data: postArgs,
            dataType: "json",
            success: nd.facebookUtils.ndConnectCallback,
            error: nd.facebookUtils.ndConnectError
        })
    }
}, nd.facebookUtils.ndConnectCallback = function (response) {
    response.success ? response.redirect_url && (-1 != response.redirect_url.indexOf("/link_account") && -1 == response.redirect_url.indexOf("mobile=1") ? (qsDict = {}, response.redirect_url.replace(RegExp("([^?=&]+)(=([^&]*))?", "g"), function ($0, $1, $2, $3) {
        qsDict[$1] = $3
    }), $("input[name='social_id']").val(qsDict.sid), $("input[name='social_network']").val(qsDict.sn), sign_up_href = $("#sign_up_link").attr("href") + "?sid=" + qsDict.sid + "&sn=" + qsDict.sn, $("#sign_up_link").attr("href", sign_up_href), $("#link_account_modal").modal(), $(".fb_login_spinner").hide(), $("#facebook_login_button").show()) : window.location = response.redirect_url) : "already_connected" == response.error ? nd.facebookUtils.ndConnectError("#facebook_already_connected_error") : nd.facebookUtils.ndConnectError()
}, nd.facebookUtils.ndConnectError = function (error_selector) {
    error_selector || (error_selector = "#facebook_connect_error"), $(error_selector).show(), $(".fb_login_spinner").hide(), $("#facebook_login_button").show()
}, nd.facebookUtils.getUserPhoto = function () {
    FB.api("/me/picture?type=large&return_ssl_resources=1", nd.facebookUtils.fbPhotoCallback)
}, nd.facebookUtils.getUserInfo = function () {
    FB.api("/me?fields=id,email,first_name,last_name,gender,bio,location,hometown,work,significant_other&return_ssl_resources=1", nd.facebookUtils.fbPersonalInfoCallback)
}, nd.facebookUtils.fbPhotoCallback = function (response) {
    response.data && response.data.url && !response.data.is_silhouette && ($("#facebook_profile_pic").attr("src", response.data.url), $("#facebook_profile_pic").show(), $("#user_profile_pic").hide(), $("#id_facebook_photo").val(response.data.url).trigger("change"))
}, nd.facebookUtils.fbPersonalInfoCallback = function (response) {
    $("#facebook_area").slideUp("slow"), response.id && ($("#id_social_id").val(response.id), $("#id_social_network").val("6")), response.email && $("#id_email").val(response.email), response.firstName && $("#id_first_name").val(response.firstName), response.lastName && $("#id_last_name").val(response.lastName), response.gender && ("male" == response.gender ? $("input[name='gender'][value='M']").attr("checked", "true") : "female" == response.gender && $("input[name='gender'][value='F']").attr("checked", "true"))
}, nd.facebookUtils.facebookSendInit = function (facebookAppId) {
    nd.facebookUtils.facebookInit(facebookAppId), $("[data-class*='facebook-method']").click(nd.facebookUtils.facebookMethod), $("#facebook_share").click(nd.facebookUtils.facebookShare)
}, nd.facebookUtils.facebookMethod = function () {
    var fbData = {}, fbLink = "";
    $.each(this.attributes, function (ind, item) {
        0 == item.name.indexOf("data-") && (fbData[item.name.substring(5)] = item.value, "link" == item.name.substring(5) && (fbLink = item.value))
    }), fbData.hasOwnProperty("method") && FB.ui(fbData, function (response) {
        $("#facebook_invite_helper_modal").hide(), $("#facebook_invite_helper_overlay").hide();
        var postId = "";
        response && response.postId && (postId = response.postId), $.getScript("/static/nextdoorv2/js/nd_tracker.js", function () {
            nd.tracker.track("Click Action", {
                target: "Facebook",
                type: fbData.method,
                link: fbLink,
                post_id: postId
            })
        })
    })
}, nd.facebookUtils.facebookShare = function () {
    var w = 550,
        h = 350;
    t = screen.height / 2 - h / 2, l = screen.width / 2 - w / 2, popupStyle = "height=" + h + ",width=" + w + ",top=" + t + ",left=" + l, popupWindow = window.open(this.getAttribute("data-url"), "", popupStyle), window.focus && popupWindow.focus()
}, nd.facebookUtils.storeSocialGraph = function (connections) {
    data = {
        network: "facebook",
        contacts: connections
    }, data = JSON.stringify(data), $.post("/ajax/social_graph/", data, function () {}, "json")
}, nd.facebookUtils.replaceField = function (selector, info) {
    !$(selector).is(":visible") || "" != $(selector).val() && $(selector).val() != $(selector).attr("title") || $(selector).val(info)
}, nd.facebookUtils.addSpouse = function (name, id) {
    spouseId = id, $("#choose_spouse select")[0].value || (extendedImport ? ($("#choose_spouse").hide(), $("#enter_spouse").show(), $("#id_spouse_freetext").val(name), $("#id_spouse_freetext").removeClass("meta"), $("#id_spouse_email").focus()) : ($(".spouse_freetext_area").css("display", "block"), $("#id_spouse_ddl").remove(), $("#id_spouse_freetext").val(name), $("#id_spouse_freetext").removeClass("meta"), $("#id_spouse_email").focus()))
};
var resp;
nd.facebookUtils.apiCall = function (code) {
    FB.api(code + "?metadata=1", function (response) {
        console.log(response), resp = response
    })
}, nd.facebookUtils.trackLoginAttempt = function () {
    var desc = "Facebook Permissions Refused";
    "connected" == nd.facebookUtils.facebookStatus ? desc = "Facebook Permissions Granted" : desc += "not_authorized" == nd.facebookUtils.facebookStatus ? " - not authorized" : " - not logged in", nd.tracker.track("UI Action", {
        description: desc,
        facebook_status: nd.facebookUtils.facebookStatus
    })
};
var nd = nd || {};
nd.addPhotoModal = nd.addPhotoModal || {}, nd.addPhotoModal.submitPhoto = function () {
    if ($("#ap_cancel, #ap_submit").hide(), $("#ap_spinner").show(), "" == $("#id_upload_photo").val() && "" == $("#id_facebook_photo").val()) return $("#no_photo_alert").removeClass("hide"), $("#ap_cancel, #ap_submit").show(), $("#ap_spinner").hide(), !1;
    var UPF = $("#upload_photo_form");
    return $.browser.msie ? (UPF.submit(), !0) : ($.ajax({
        type: "POST",
        url: UPF.attr("action"),
        data: new FormData(UPF[0]),
        success: nd.addPhotoModal.submitPhotoSuccess,
        cache: !1,
        contentType: !1,
        processData: !1
    }), !1)
}, nd.addPhotoModal.submitPhotoSuccess = function () {
    nd.addPhotoModal.closePhotoModal(), location.reload()
}, nd.addPhotoModal.closePhotoModal = function () {
    $("#no_photo_alert").addClass("hide"), $("#add_photo_modal").modal("hide")
}, nd.addPhotoModal.initAddPhotoModal = function () {
    var facebookAppId = $("#facebook_app_id").val();
    $("#ap_submit").one("click", function () {
        nd.addPhotoModal.submitPhoto()
    }), $("#add_photo_modal_link").click(function () {
        $("#add_photo_modal").modal()
    }), $("#ap_cancel").click(function () {
        nd.addPhotoModal.closePhotoModal()
    }), nd.facebookUtils.facebookInit(facebookAppId, null, function (q) {
        $("#id_upload_photo").val(""), nd.facebookUtils.getUserPhoto(q)
    }), $("#id_upload_photo").change(function () {
        $('#upload_photo_form [name^="facebook"]').val("")
    }), $("#id_upload_photo").change(function () {
        $("#no_photo_alert").addClass("hide")
    }), $("#id_facebook_photo").change(function () {
        $("#no_photo_alert").addClass("hide")
    })
}, $(document).ready(nd.addPhotoModal.initAddPhotoModal),
function (e, t) {
    function i(t, n) {
        var r, i, o, u = t.nodeName.toLowerCase();
        return "area" === u ? (r = t.parentNode, i = r.name, t.href && i && "map" === r.nodeName.toLowerCase() ? (o = e("img[usemap=#" + i + "]")[0], !! o && s(o)) : !1) : (/input|select|textarea|button|object/.test(u) ? !t.disabled : "a" === u ? t.href || n : n) && s(t)
    }

    function s(t) {
        return e.expr.filters.visible(t) && !e(t).parents().andSelf().filter(function () {
            return "hidden" === e.css(this, "visibility")
        }).length
    }
    var n = 0,
        r = /^ui-id-\d+$/;
    e.ui = e.ui || {}, e.ui.version || (e.extend(e.ui, {
        version: "1.9.2",
        keyCode: {
            BACKSPACE: 8,
            COMMA: 188,
            DELETE: 46,
            DOWN: 40,
            END: 35,
            ENTER: 13,
            ESCAPE: 27,
            HOME: 36,
            LEFT: 37,
            NUMPAD_ADD: 107,
            NUMPAD_DECIMAL: 110,
            NUMPAD_DIVIDE: 111,
            NUMPAD_ENTER: 108,
            NUMPAD_MULTIPLY: 106,
            NUMPAD_SUBTRACT: 109,
            PAGE_DOWN: 34,
            PAGE_UP: 33,
            PERIOD: 190,
            RIGHT: 39,
            SPACE: 32,
            TAB: 9,
            UP: 38
        }
    }), e.fn.extend({
        _focus: e.fn.focus,
        focus: function (t, n) {
            return "number" == typeof t ? this.each(function () {
                var r = this;
                setTimeout(function () {
                    e(r).focus(), n && n.call(r)
                }, t)
            }) : this._focus.apply(this, arguments)
        },
        scrollParent: function () {
            var t;
            return t = e.ui.ie && /(static|relative)/.test(this.css("position")) || /absolute/.test(this.css("position")) ? this.parents().filter(function () {
                return /(relative|absolute|fixed)/.test(e.css(this, "position")) && /(auto|scroll)/.test(e.css(this, "overflow") + e.css(this, "overflow-y") + e.css(this, "overflow-x"))
            }).eq(0) : this.parents().filter(function () {
                return /(auto|scroll)/.test(e.css(this, "overflow") + e.css(this, "overflow-y") + e.css(this, "overflow-x"))
            }).eq(0), /fixed/.test(this.css("position")) || !t.length ? e(document) : t
        },
        zIndex: function (n) {
            if (n !== t) return this.css("zIndex", n);
            if (this.length)
                for (var i, s, r = e(this[0]); r.length && r[0] !== document;) {
                    if (i = r.css("position"), ("absolute" === i || "relative" === i || "fixed" === i) && (s = parseInt(r.css("zIndex"), 10), !isNaN(s) && 0 !== s)) return s;
                    r = r.parent()
                }
            return 0
        },
        uniqueId: function () {
            return this.each(function () {
                this.id || (this.id = "ui-id-" + ++n)
            })
        },
        removeUniqueId: function () {
            return this.each(function () {
                r.test(this.id) && e(this).removeAttr("id")
            })
        }
    }), e.extend(e.expr[":"], {
        data: e.expr.createPseudo ? e.expr.createPseudo(function (t) {
            return function (n) {
                return !!e.data(n, t)
            }
        }) : function (t, n, r) {
            return !!e.data(t, r[3])
        },
        focusable: function (t) {
            return i(t, !isNaN(e.attr(t, "tabindex")))
        },
        tabbable: function (t) {
            var n = e.attr(t, "tabindex"),
                r = isNaN(n);
            return (r || n >= 0) && i(t, !r)
        }
    }), e(function () {
        var t = document.body,
            n = t.appendChild(n = document.createElement("div"));
        n.offsetHeight, e.extend(n.style, {
            minHeight: "100px",
            height: "auto",
            padding: 0,
            borderWidth: 0
        }), e.support.minHeight = 100 === n.offsetHeight, e.support.selectstart = "onselectstart" in n, t.removeChild(n).style.display = "none"
    }), e("<a>").outerWidth(1).jquery || e.each(["Width", "Height"], function (n, r) {
        function u(t, n, r, s) {
            return e.each(i, function () {
                n -= parseFloat(e.css(t, "padding" + this)) || 0, r && (n -= parseFloat(e.css(t, "border" + this + "Width")) || 0), s && (n -= parseFloat(e.css(t, "margin" + this)) || 0)
            }), n
        }
        var i = "Width" === r ? ["Left", "Right"] : ["Top", "Bottom"],
            s = r.toLowerCase(),
            o = {
                innerWidth: e.fn.innerWidth,
                innerHeight: e.fn.innerHeight,
                outerWidth: e.fn.outerWidth,
                outerHeight: e.fn.outerHeight
            };
        e.fn["inner" + r] = function (n) {
            return n === t ? o["inner" + r].call(this) : this.each(function () {
                e(this).css(s, u(this, n) + "px")
            })
        }, e.fn["outer" + r] = function (t, n) {
            return "number" != typeof t ? o["outer" + r].call(this, t) : this.each(function () {
                e(this).css(s, u(this, t, !0, n) + "px")
            })
        }
    }), e("<a>").data("a-b", "a").removeData("a-b").data("a-b") && (e.fn.removeData = function (t) {
        return function (n) {
            return arguments.length ? t.call(this, e.camelCase(n)) : t.call(this)
        }
    }(e.fn.removeData)), function () {
        var t = /msie ([\w.]+)/.exec(navigator.userAgent.toLowerCase()) || [];
        e.ui.ie = t.length ? !0 : !1, e.ui.ie6 = 6 === parseFloat(t[1], 10)
    }(), e.fn.extend({
        disableSelection: function () {
            return this.bind((e.support.selectstart ? "selectstart" : "mousedown") + ".ui-disableSelection", function (e) {
                e.preventDefault()
            })
        },
        enableSelection: function () {
            return this.unbind(".ui-disableSelection")
        }
    }), e.extend(e.ui, {
        plugin: {
            add: function (t, n, r) {
                var i, s = e.ui[t].prototype;
                for (i in r) s.plugins[i] = s.plugins[i] || [], s.plugins[i].push([n, r[i]])
            },
            call: function (e, t, n) {
                var r, i = e.plugins[t];
                if (i && e.element[0].parentNode && 11 !== e.element[0].parentNode.nodeType)
                    for (r = 0; i.length > r; r++) e.options[i[r][0]] && i[r][1].apply(e.element, n)
            }
        },
        contains: e.contains,
        hasScroll: function (t, n) {
            if ("hidden" === e(t).css("overflow")) return !1;
            var r = n && "left" === n ? "scrollLeft" : "scrollTop",
                i = !1;
            return t[r] > 0 ? !0 : (t[r] = 1, i = t[r] > 0, t[r] = 0, i)
        },
        isOverAxis: function (e, t, n) {
            return e > t && t + n > e
        },
        isOver: function (t, n, r, i, s, o) {
            return e.ui.isOverAxis(t, r, s) && e.ui.isOverAxis(n, i, o)
        }
    }))
}(jQuery),
function (e, t) {
    var n = 0,
        r = Array.prototype.slice,
        i = e.cleanData;
    e.cleanData = function (t) {
        for (var r, n = 0; null != (r = t[n]); n++) try {
            e(r).triggerHandler("remove")
        } catch (s) {}
        i(t)
    }, e.widget = function (t, n, r) {
        var i, s, o, u, a = t.split(".")[0];
        t = t.split(".")[1], i = a + "-" + t, r || (r = n, n = e.Widget), e.expr[":"][i.toLowerCase()] = function (t) {
            return !!e.data(t, i)
        }, e[a] = e[a] || {}, s = e[a][t], o = e[a][t] = function (e, t) {
            return this._createWidget ? (arguments.length && this._createWidget(e, t), void 0) : new o(e, t)
        }, e.extend(o, s, {
            version: r.version,
            _proto: e.extend({}, r),
            _childConstructors: []
        }), u = new n, u.options = e.widget.extend({}, u.options), e.each(r, function (t, i) {
            e.isFunction(i) && (r[t] = function () {
                var e = function () {
                    return n.prototype[t].apply(this, arguments)
                }, r = function (e) {
                        return n.prototype[t].apply(this, e)
                    };
                return function () {
                    var s, t = this._super,
                        n = this._superApply;
                    return this._super = e, this._superApply = r, s = i.apply(this, arguments), this._super = t, this._superApply = n, s
                }
            }())
        }), o.prototype = e.widget.extend(u, {
            widgetEventPrefix: s ? u.widgetEventPrefix : t
        }, r, {
            constructor: o,
            namespace: a,
            widgetName: t,
            widgetBaseClass: i,
            widgetFullName: i
        }), s ? (e.each(s._childConstructors, function (t, n) {
            var r = n.prototype;
            e.widget(r.namespace + "." + r.widgetName, o, n._proto)
        }), delete s._childConstructors) : n._childConstructors.push(o), e.widget.bridge(t, o)
    }, e.widget.extend = function (n) {
        for (var u, a, i = r.call(arguments, 1), s = 0, o = i.length; o > s; s++)
            for (u in i[s]) a = i[s][u], i[s].hasOwnProperty(u) && a !== t && (n[u] = e.isPlainObject(a) ? e.isPlainObject(n[u]) ? e.widget.extend({}, n[u], a) : e.widget.extend({}, a) : a);
        return n
    }, e.widget.bridge = function (n, i) {
        var s = i.prototype.widgetFullName || n;
        e.fn[n] = function (o) {
            var u = "string" == typeof o,
                a = r.call(arguments, 1),
                f = this;
            return o = !u && a.length ? e.widget.extend.apply(null, [o].concat(a)) : o, u ? this.each(function () {
                var r, i = e.data(this, s);
                return i ? e.isFunction(i[o]) && "_" !== o.charAt(0) ? (r = i[o].apply(i, a), r !== i && r !== t ? (f = r && r.jquery ? f.pushStack(r.get()) : r, !1) : void 0) : e.error("no such method '" + o + "' for " + n + " widget instance") : e.error("cannot call methods on " + n + " prior to initialization; " + "attempted to call method '" + o + "'")
            }) : this.each(function () {
                var t = e.data(this, s);
                t ? t.option(o || {})._init() : e.data(this, s, new i(o, this))
            }), f
        }
    }, e.Widget = function () {}, e.Widget._childConstructors = [], e.Widget.prototype = {
        widgetName: "widget",
        widgetEventPrefix: "",
        defaultElement: "<div>",
        options: {
            disabled: !1,
            create: null
        },
        _createWidget: function (t, r) {
            r = e(r || this.defaultElement || this)[0], this.element = e(r), this.uuid = n++, this.eventNamespace = "." + this.widgetName + this.uuid, this.options = e.widget.extend({}, this.options, this._getCreateOptions(), t), this.bindings = e(), this.hoverable = e(), this.focusable = e(), r !== this && (e.data(r, this.widgetName, this), e.data(r, this.widgetFullName, this), this._on(!0, this.element, {
                remove: function (e) {
                    e.target === r && this.destroy()
                }
            }), this.document = e(r.style ? r.ownerDocument : r.document || r), this.window = e(this.document[0].defaultView || this.document[0].parentWindow)), this._create(), this._trigger("create", null, this._getCreateEventData()), this._init()
        },
        _getCreateOptions: e.noop,
        _getCreateEventData: e.noop,
        _create: e.noop,
        _init: e.noop,
        destroy: function () {
            this._destroy(), this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)), this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName + "-disabled " + "ui-state-disabled"), this.bindings.unbind(this.eventNamespace), this.hoverable.removeClass("ui-state-hover"), this.focusable.removeClass("ui-state-focus")
        },
        _destroy: e.noop,
        widget: function () {
            return this.element
        },
        option: function (n, r) {
            var s, o, u, i = n;
            if (0 === arguments.length) return e.widget.extend({}, this.options);
            if ("string" == typeof n)
                if (i = {}, s = n.split("."), n = s.shift(), s.length) {
                    for (o = i[n] = e.widget.extend({}, this.options[n]), u = 0; s.length - 1 > u; u++) o[s[u]] = o[s[u]] || {}, o = o[s[u]];
                    if (n = s.pop(), r === t) return o[n] === t ? null : o[n];
                    o[n] = r
                } else {
                    if (r === t) return this.options[n] === t ? null : this.options[n];
                    i[n] = r
                }
            return this._setOptions(i), this
        },
        _setOptions: function (e) {
            var t;
            for (t in e) this._setOption(t, e[t]);
            return this
        },
        _setOption: function (e, t) {
            return this.options[e] = t, "disabled" === e && (this.widget().toggleClass(this.widgetFullName + "-disabled ui-state-disabled", !! t).attr("aria-disabled", t), this.hoverable.removeClass("ui-state-hover"), this.focusable.removeClass("ui-state-focus")), this
        },
        enable: function () {
            return this._setOption("disabled", !1)
        },
        disable: function () {
            return this._setOption("disabled", !0)
        },
        _on: function (t, n, r) {
            var i, s = this;
            "boolean" != typeof t && (r = n, n = t, t = !1), r ? (n = i = e(n), this.bindings = this.bindings.add(n)) : (r = n, n = this.element, i = this.widget()), e.each(r, function (r, o) {
                function u() {
                    return t || s.options.disabled !== !0 && !e(this).hasClass("ui-state-disabled") ? ("string" == typeof o ? s[o] : o).apply(s, arguments) : void 0
                }
                "string" != typeof o && (u.guid = o.guid = o.guid || u.guid || e.guid++);
                var a = r.match(/^(\w+)\s*(.*)$/),
                    f = a[1] + s.eventNamespace,
                    l = a[2];
                l ? i.delegate(l, f, u) : n.bind(f, u)
            })
        },
        _off: function (e, t) {
            t = (t || "").split(" ").join(this.eventNamespace + " ") + this.eventNamespace, e.unbind(t).undelegate(t)
        },
        _delay: function (e, t) {
            function n() {
                return ("string" == typeof e ? r[e] : e).apply(r, arguments)
            }
            var r = this;
            return setTimeout(n, t || 0)
        },
        _hoverable: function (t) {
            this.hoverable = this.hoverable.add(t), this._on(t, {
                mouseenter: function (t) {
                    e(t.currentTarget).addClass("ui-state-hover")
                },
                mouseleave: function (t) {
                    e(t.currentTarget).removeClass("ui-state-hover")
                }
            })
        },
        _focusable: function (t) {
            this.focusable = this.focusable.add(t), this._on(t, {
                focusin: function (t) {
                    e(t.currentTarget).addClass("ui-state-focus")
                },
                focusout: function (t) {
                    e(t.currentTarget).removeClass("ui-state-focus")
                }
            })
        },
        _trigger: function (t, n, r) {
            var i, s, o = this.options[t];
            if (r = r || {}, n = e.Event(n), n.type = (t === this.widgetEventPrefix ? t : this.widgetEventPrefix + t).toLowerCase(), n.target = this.element[0], s = n.originalEvent, s)
                for (i in s) i in n || (n[i] = s[i]);
            return this.element.trigger(n, r), !(e.isFunction(o) && o.apply(this.element[0], [n].concat(r)) === !1 || n.isDefaultPrevented())
        }
    }, e.each({
        show: "fadeIn",
        hide: "fadeOut"
    }, function (t, n) {
        e.Widget.prototype["_" + t] = function (r, i, s) {
            "string" == typeof i && (i = {
                effect: i
            });
            var o, u = i ? i === !0 || "number" == typeof i ? n : i.effect || n : t;
            i = i || {}, "number" == typeof i && (i = {
                duration: i
            }), o = !e.isEmptyObject(i), i.complete = s, i.delay && r.delay(i.delay), o && e.effects && (e.effects.effect[u] || e.uiBackCompat !== !1 && e.effects[u]) ? r[t](i) : u !== t && r[u] ? r[u](i.duration, i.easing, s) : r.queue(function (n) {
                e(this)[t](), s && s.call(r[0]), n()
            })
        }
    }), e.uiBackCompat !== !1 && (e.Widget.prototype._getCreateOptions = function () {
        return e.metadata && e.metadata.get(this.element[0])[this.widgetName]
    })
}(jQuery),
function (e, t) {
    function h(e, t, n) {
        return [parseInt(e[0], 10) * (l.test(e[0]) ? t / 100 : 1), parseInt(e[1], 10) * (l.test(e[1]) ? n / 100 : 1)]
    }

    function p(t, n) {
        return parseInt(e.css(t, n), 10) || 0
    }
    e.ui = e.ui || {};
    var n, r = Math.max,
        i = Math.abs,
        s = Math.round,
        o = /left|center|right/,
        u = /top|center|bottom/,
        a = /[\+\-]\d+%?/,
        f = /^\w+/,
        l = /%$/,
        c = e.fn.position;
    e.position = {
        scrollbarWidth: function () {
            if (n !== t) return n;
            var r, i, s = e("<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),
                o = s.children()[0];
            return e("body").append(s), r = o.offsetWidth, s.css("overflow", "scroll"), i = o.offsetWidth, r === i && (i = s[0].clientWidth), s.remove(), n = r - i
        },
        getScrollInfo: function (t) {
            var n = t.isWindow ? "" : t.element.css("overflow-x"),
                r = t.isWindow ? "" : t.element.css("overflow-y"),
                i = "scroll" === n || "auto" === n && t.width < t.element[0].scrollWidth,
                s = "scroll" === r || "auto" === r && t.height < t.element[0].scrollHeight;
            return {
                width: i ? e.position.scrollbarWidth() : 0,
                height: s ? e.position.scrollbarWidth() : 0
            }
        },
        getWithinInfo: function (t) {
            var n = e(t || window),
                r = e.isWindow(n[0]);
            return {
                element: n,
                isWindow: r,
                offset: n.offset() || {
                    left: 0,
                    top: 0
                },
                scrollLeft: n.scrollLeft(),
                scrollTop: n.scrollTop(),
                width: r ? n.width() : n.outerWidth(),
                height: r ? n.height() : n.outerHeight()
            }
        }
    }, e.fn.position = function (t) {
        if (!t || !t.of) return c.apply(this, arguments);
        t = e.extend({}, t);
        var n, l, d, v, m, g = e(t.of),
            y = e.position.getWithinInfo(t.within),
            b = e.position.getScrollInfo(y),
            w = g[0],
            E = (t.collision || "flip").split(" "),
            S = {};
        return 9 === w.nodeType ? (l = g.width(), d = g.height(), v = {
            top: 0,
            left: 0
        }) : e.isWindow(w) ? (l = g.width(), d = g.height(), v = {
            top: g.scrollTop(),
            left: g.scrollLeft()
        }) : w.preventDefault ? (t.at = "left top", l = d = 0, v = {
            top: w.pageY,
            left: w.pageX
        }) : (l = g.outerWidth(), d = g.outerHeight(), v = g.offset()), m = e.extend({}, v), e.each(["my", "at"], function () {
            var n, r, e = (t[this] || "").split(" ");
            1 === e.length && (e = o.test(e[0]) ? e.concat(["center"]) : u.test(e[0]) ? ["center"].concat(e) : ["center", "center"]), e[0] = o.test(e[0]) ? e[0] : "center", e[1] = u.test(e[1]) ? e[1] : "center", n = a.exec(e[0]), r = a.exec(e[1]), S[this] = [n ? n[0] : 0, r ? r[0] : 0], t[this] = [f.exec(e[0])[0], f.exec(e[1])[0]]
        }), 1 === E.length && (E[1] = E[0]), "right" === t.at[0] ? m.left += l : "center" === t.at[0] && (m.left += l / 2), "bottom" === t.at[1] ? m.top += d : "center" === t.at[1] && (m.top += d / 2), n = h(S.at, l, d), m.left += n[0], m.top += n[1], this.each(function () {
            var o, u, a = e(this),
                f = a.outerWidth(),
                c = a.outerHeight(),
                w = p(this, "marginLeft"),
                x = p(this, "marginTop"),
                T = f + w + p(this, "marginRight") + b.width,
                N = c + x + p(this, "marginBottom") + b.height,
                C = e.extend({}, m),
                k = h(S.my, a.outerWidth(), a.outerHeight());
            "right" === t.my[0] ? C.left -= f : "center" === t.my[0] && (C.left -= f / 2), "bottom" === t.my[1] ? C.top -= c : "center" === t.my[1] && (C.top -= c / 2), C.left += k[0], C.top += k[1], e.support.offsetFractions || (C.left = s(C.left), C.top = s(C.top)), o = {
                marginLeft: w,
                marginTop: x
            }, e.each(["left", "top"], function (r, i) {
                e.ui.position[E[r]] && e.ui.position[E[r]][i](C, {
                    targetWidth: l,
                    targetHeight: d,
                    elemWidth: f,
                    elemHeight: c,
                    collisionPosition: o,
                    collisionWidth: T,
                    collisionHeight: N,
                    offset: [n[0] + k[0], n[1] + k[1]],
                    my: t.my,
                    at: t.at,
                    within: y,
                    elem: a
                })
            }), e.fn.bgiframe && a.bgiframe(), t.using && (u = function (e) {
                var n = v.left - C.left,
                    s = n + l - f,
                    o = v.top - C.top,
                    u = o + d - c,
                    h = {
                        target: {
                            element: g,
                            left: v.left,
                            top: v.top,
                            width: l,
                            height: d
                        },
                        element: {
                            element: a,
                            left: C.left,
                            top: C.top,
                            width: f,
                            height: c
                        },
                        horizontal: 0 > s ? "left" : n > 0 ? "right" : "center",
                        vertical: 0 > u ? "top" : o > 0 ? "bottom" : "middle"
                    };
                f > l && l > i(n + s) && (h.horizontal = "center"), c > d && d > i(o + u) && (h.vertical = "middle"), h.important = r(i(n), i(s)) > r(i(o), i(u)) ? "horizontal" : "vertical", t.using.call(this, e, h)
            }), a.offset(e.extend(C, {
                using: u
            }))
        })
    }, e.ui.position = {
        fit: {
            left: function (e, t) {
                var f, n = t.within,
                    i = n.isWindow ? n.scrollLeft : n.offset.left,
                    s = n.width,
                    o = e.left - t.collisionPosition.marginLeft,
                    u = i - o,
                    a = o + t.collisionWidth - s - i;
                t.collisionWidth > s ? u > 0 && 0 >= a ? (f = e.left + u + t.collisionWidth - s - i, e.left += u - f) : e.left = a > 0 && 0 >= u ? i : u > a ? i + s - t.collisionWidth : i : u > 0 ? e.left += u : a > 0 ? e.left -= a : e.left = r(e.left - o, e.left)
            },
            top: function (e, t) {
                var f, n = t.within,
                    i = n.isWindow ? n.scrollTop : n.offset.top,
                    s = t.within.height,
                    o = e.top - t.collisionPosition.marginTop,
                    u = i - o,
                    a = o + t.collisionHeight - s - i;
                t.collisionHeight > s ? u > 0 && 0 >= a ? (f = e.top + u + t.collisionHeight - s - i, e.top += u - f) : e.top = a > 0 && 0 >= u ? i : u > a ? i + s - t.collisionHeight : i : u > 0 ? e.top += u : a > 0 ? e.top -= a : e.top = r(e.top - o, e.top)
            }
        },
        flip: {
            left: function (e, t) {
                var p, d, n = t.within,
                    r = n.offset.left + n.scrollLeft,
                    s = n.width,
                    o = n.isWindow ? n.scrollLeft : n.offset.left,
                    u = e.left - t.collisionPosition.marginLeft,
                    a = u - o,
                    f = u + t.collisionWidth - s - o,
                    l = "left" === t.my[0] ? -t.elemWidth : "right" === t.my[0] ? t.elemWidth : 0,
                    c = "left" === t.at[0] ? t.targetWidth : "right" === t.at[0] ? -t.targetWidth : 0,
                    h = -2 * t.offset[0];
                0 > a ? (p = e.left + l + c + h + t.collisionWidth - s - r, (0 > p || i(a) > p) && (e.left += l + c + h)) : f > 0 && (d = e.left - t.collisionPosition.marginLeft + l + c + h - o, (d > 0 || f > i(d)) && (e.left += l + c + h))
            },
            top: function (e, t) {
                var d, v, n = t.within,
                    r = n.offset.top + n.scrollTop,
                    s = n.height,
                    o = n.isWindow ? n.scrollTop : n.offset.top,
                    u = e.top - t.collisionPosition.marginTop,
                    a = u - o,
                    f = u + t.collisionHeight - s - o,
                    l = "top" === t.my[1],
                    c = l ? -t.elemHeight : "bottom" === t.my[1] ? t.elemHeight : 0,
                    h = "top" === t.at[1] ? t.targetHeight : "bottom" === t.at[1] ? -t.targetHeight : 0,
                    p = -2 * t.offset[1];
                0 > a ? (v = e.top + c + h + p + t.collisionHeight - s - r, e.top + c + h + p > a && (0 > v || i(a) > v) && (e.top += c + h + p)) : f > 0 && (d = e.top - t.collisionPosition.marginTop + c + h + p - o, e.top + c + h + p > f && (d > 0 || f > i(d)) && (e.top += c + h + p))
            }
        },
        flipfit: {
            left: function () {
                e.ui.position.flip.left.apply(this, arguments), e.ui.position.fit.left.apply(this, arguments)
            },
            top: function () {
                e.ui.position.flip.top.apply(this, arguments), e.ui.position.fit.top.apply(this, arguments)
            }
        }
    },
    function () {
        var t, n, r, i, s, o = document.getElementsByTagName("body")[0],
            u = document.createElement("div");
        t = document.createElement(o ? "div" : "body"), r = {
            visibility: "hidden",
            width: 0,
            height: 0,
            border: 0,
            margin: 0,
            background: "none"
        }, o && e.extend(r, {
            position: "absolute",
            left: "-1000px",
            top: "-1000px"
        });
        for (s in r) t.style[s] = r[s];
        t.appendChild(u), n = o || document.documentElement, n.insertBefore(t, n.firstChild), u.style.cssText = "position: absolute; left: 10.7432222px;", i = e(u).offset().left, e.support.offsetFractions = i > 10 && 11 > i, t.innerHTML = "", n.removeChild(t)
    }(), e.uiBackCompat !== !1 && function (e) {
        var n = e.fn.position;
        e.fn.position = function (r) {
            if (!r || !r.offset) return n.call(this, r);
            var i = r.offset.split(" "),
                s = r.at.split(" ");
            return 1 === i.length && (i[1] = i[0]), /^\d/.test(i[0]) && (i[0] = "+" + i[0]), /^\d/.test(i[1]) && (i[1] = "+" + i[1]), 1 === s.length && (/left|center|right/.test(s[0]) ? s[1] = "center" : (s[1] = s[0], s[0] = "center")), n.call(this, e.extend(r, {
                at: s[0] + i[0] + " " + s[1] + i[1],
                offset: t
            }))
        }
    }(jQuery)
}(jQuery),
function (e) {
    var n = 0;
    e.widget("ui.autocomplete", {
        version: "1.9.2",
        defaultElement: "<input>",
        options: {
            appendTo: "body",
            autoFocus: !1,
            delay: 300,
            minLength: 1,
            position: {
                my: "left top",
                at: "left bottom",
                collision: "none"
            },
            source: null,
            change: null,
            close: null,
            focus: null,
            open: null,
            response: null,
            search: null,
            select: null
        },
        pending: 0,
        _create: function () {
            var t, n, r;
            this.isMultiLine = this._isMultiLine(), this.valueMethod = this.element[this.element.is("input,textarea") ? "val" : "text"], this.isNewMenu = !0, this.element.addClass("ui-autocomplete-input").attr("autocomplete", "off"), this._on(this.element, {
                keydown: function (i) {
                    if (this.element.prop("readOnly")) return t = !0, r = !0, n = !0, void 0;
                    t = !1, r = !1, n = !1;
                    var s = e.ui.keyCode;
                    switch (i.keyCode) {
                    case s.PAGE_UP:
                        t = !0, this._move("previousPage", i);
                        break;
                    case s.PAGE_DOWN:
                        t = !0, this._move("nextPage", i);
                        break;
                    case s.UP:
                        t = !0, this._keyEvent("previous", i);
                        break;
                    case s.DOWN:
                        t = !0, this._keyEvent("next", i);
                        break;
                    case s.ENTER:
                    case s.NUMPAD_ENTER:
                        this.menu.active && (t = !0, i.preventDefault(), this.menu.select(i));
                        break;
                    case s.TAB:
                        this.menu.active && this.menu.select(i);
                        break;
                    case s.ESCAPE:
                        this.menu.element.is(":visible") && (this._value(this.term), this.close(i), i.preventDefault());
                        break;
                    default:
                        n = !0, this._searchTimeout(i)
                    }
                },
                keypress: function (r) {
                    if (t) return t = !1, r.preventDefault(), void 0;
                    if (!n) {
                        var i = e.ui.keyCode;
                        switch (r.keyCode) {
                        case i.PAGE_UP:
                            this._move("previousPage", r);
                            break;
                        case i.PAGE_DOWN:
                            this._move("nextPage", r);
                            break;
                        case i.UP:
                            this._keyEvent("previous", r);
                            break;
                        case i.DOWN:
                            this._keyEvent("next", r)
                        }
                    }
                },
                input: function (e) {
                    return r ? (r = !1, e.preventDefault(), void 0) : (this._searchTimeout(e), void 0)
                },
                focus: function () {
                    this.selectedItem = null, this.previous = this._value()
                },
                blur: function (e) {
                    return this.cancelBlur ? (delete this.cancelBlur, void 0) : (clearTimeout(this.searching), this.close(e), this._change(e), void 0)
                }
            }), this._initSource(), this.menu = e("<ul>").addClass("ui-autocomplete").appendTo(this.document.find(this.options.appendTo || "body")[0]).menu({
                input: e(),
                role: null
            }).zIndex(this.element.zIndex() + 1).hide().data("menu"), this._on(this.menu.element, {
                mousedown: function (t) {
                    t.preventDefault(), this.cancelBlur = !0, this._delay(function () {
                        delete this.cancelBlur
                    });
                    var n = this.menu.element[0];
                    e(t.target).closest(".ui-menu-item").length || this._delay(function () {
                        var t = this;
                        this.document.one("mousedown", function (r) {
                            r.target !== t.element[0] && r.target !== n && !e.contains(n, r.target) && t.close()
                        })
                    })
                },
                menufocus: function (t, n) {
                    if (this.isNewMenu && (this.isNewMenu = !1, t.originalEvent && /^mouse/.test(t.originalEvent.type))) return this.menu.blur(), this.document.one("mousemove", function () {
                        e(t.target).trigger(t.originalEvent)
                    }), void 0;
                    var r = n.item.data("ui-autocomplete-item") || n.item.data("item.autocomplete");
                    !1 !== this._trigger("focus", t, {
                        item: r
                    }) ? t.originalEvent && /^key/.test(t.originalEvent.type) && this._value(r.value) : this.liveRegion.text(r.value)
                },
                menuselect: function (e, t) {
                    var n = t.item.data("ui-autocomplete-item") || t.item.data("item.autocomplete"),
                        r = this.previous;
                    this.element[0] !== this.document[0].activeElement && (this.element.focus(), this.previous = r, this._delay(function () {
                        this.previous = r, this.selectedItem = n
                    })), !1 !== this._trigger("select", e, {
                        item: n
                    }) && this._value(n.value), this.term = this._value(), this.close(e), this.selectedItem = n
                }
            }), this.liveRegion = e("<span>", {
                role: "status",
                "aria-live": "polite"
            }).addClass("ui-helper-hidden-accessible").insertAfter(this.element), e.fn.bgiframe && this.menu.element.bgiframe(), this._on(this.window, {
                beforeunload: function () {
                    this.element.removeAttr("autocomplete")
                }
            })
        },
        _destroy: function () {
            clearTimeout(this.searching), this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete"), this.menu.element.remove(), this.liveRegion.remove()
        },
        _setOption: function (e, t) {
            this._super(e, t), "source" === e && this._initSource(), "appendTo" === e && this.menu.element.appendTo(this.document.find(t || "body")[0]), "disabled" === e && t && this.xhr && this.xhr.abort()
        },
        _isMultiLine: function () {
            return this.element.is("textarea") ? !0 : this.element.is("input") ? !1 : this.element.prop("isContentEditable")
        },
        _initSource: function () {
            var t, n, r = this;
            e.isArray(this.options.source) ? (t = this.options.source, this.source = function (n, r) {
                r(e.ui.autocomplete.filter(t, n.term))
            }) : "string" == typeof this.options.source ? (n = this.options.source, this.source = function (t, i) {
                r.xhr && r.xhr.abort(), r.xhr = e.ajax({
                    url: n,
                    data: t,
                    dataType: "json",
                    success: function (e) {
                        i(e)
                    },
                    error: function () {
                        i([])
                    }
                })
            }) : this.source = this.options.source
        },
        _searchTimeout: function (e) {
            clearTimeout(this.searching), this.searching = this._delay(function () {
                this.term !== this._value() && (this.selectedItem = null, this.search(null, e))
            }, this.options.delay)
        },
        search: function (e, t) {
            return e = null != e ? e : this._value(), this.term = this._value(), e.length < this.options.minLength ? this.close(t) : this._trigger("search", t) !== !1 ? this._search(e) : void 0
        },
        _search: function (e) {
            this.pending++, this.element.addClass("ui-autocomplete-loading"), this.cancelSearch = !1, this.source({
                term: e
            }, this._response())
        },
        _response: function () {
            var e = this,
                t = ++n;
            return function (r) {
                t === n && e.__response(r), e.pending--, e.pending || e.element.removeClass("ui-autocomplete-loading")
            }
        },
        __response: function (e) {
            e && (e = this._normalize(e)), this._trigger("response", null, {
                content: e
            }), !this.options.disabled && e && e.length && !this.cancelSearch ? (this._suggest(e), this._trigger("open")) : this._close()
        },
        close: function (e) {
            this.cancelSearch = !0, this._close(e)
        },
        _close: function (e) {
            this.menu.element.is(":visible") && (this.menu.element.hide(), this.menu.blur(), this.isNewMenu = !0, this._trigger("close", e))
        },
        _change: function (e) {
            this.previous !== this._value() && this._trigger("change", e, {
                item: this.selectedItem
            })
        },
        _normalize: function (t) {
            return t.length && t[0].label && t[0].value ? t : e.map(t, function (t) {
                return "string" == typeof t ? {
                    label: t,
                    value: t
                } : e.extend({
                    label: t.label || t.value,
                    value: t.value || t.label
                }, t)
            })
        },
        _suggest: function (t) {
            var n = this.menu.element.empty().zIndex(this.element.zIndex() + 1);
            this._renderMenu(n, t), this.menu.refresh(), n.show(), this._resizeMenu(), n.position(e.extend({
                of: this.element
            }, this.options.position)), this.options.autoFocus && this.menu.next()
        },
        _resizeMenu: function () {
            var e = this.menu.element;
            e.outerWidth(Math.max(e.width("").outerWidth() + 1, this.element.outerWidth()))
        },
        _renderMenu: function (t, n) {
            var r = this;
            e.each(n, function (e, n) {
                r._renderItemData(t, n)
            })
        },
        _renderItemData: function (e, t) {
            return this._renderItem(e, t).data("ui-autocomplete-item", t)
        },
        _renderItem: function (t, n) {
            return e("<li>").append(e("<a>").text(n.label)).appendTo(t)
        },
        _move: function (e, t) {
            return this.menu.element.is(":visible") ? this.menu.isFirstItem() && /^previous/.test(e) || this.menu.isLastItem() && /^next/.test(e) ? (this._value(this.term), this.menu.blur(), void 0) : (this.menu[e](t), void 0) : (this.search(null, t), void 0)
        },
        widget: function () {
            return this.menu.element
        },
        _value: function () {
            return this.valueMethod.apply(this.element, arguments)
        },
        _keyEvent: function (e, t) {
            (!this.isMultiLine || this.menu.element.is(":visible")) && (this._move(e, t), t.preventDefault())
        }
    }), e.extend(e.ui.autocomplete, {
        escapeRegex: function (e) {
            return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&")
        },
        filter: function (t, n) {
            var r = RegExp(e.ui.autocomplete.escapeRegex(n), "i");
            return e.grep(t, function (e) {
                return r.test(e.label || e.value || e)
            })
        }
    }), e.widget("ui.autocomplete", e.ui.autocomplete, {
        options: {
            messages: {
                noResults: "No search results.",
                results: function (e) {
                    return e + (e > 1 ? " results are" : " result is") + " available, use up and down arrow keys to navigate."
                }
            }
        },
        __response: function (e) {
            var t;
            this._superApply(arguments), this.options.disabled || this.cancelSearch || (t = e && e.length ? this.options.messages.results(e.length) : this.options.messages.noResults, this.liveRegion.text(t))
        }
    })
}(jQuery),
function ($, undefined) {
    function Datepicker() {
        this.debug = !1, this._curInst = null, this._keyEvent = !1, this._disabledInputs = [], this._datepickerShowing = !1, this._inDialog = !1, this._mainDivId = "ui-datepicker-div", this._inlineClass = "ui-datepicker-inline", this._appendClass = "ui-datepicker-append", this._triggerClass = "ui-datepicker-trigger", this._dialogClass = "ui-datepicker-dialog", this._disableClass = "ui-datepicker-disabled", this._unselectableClass = "ui-datepicker-unselectable", this._currentClass = "ui-datepicker-current-day", this._dayOverClass = "ui-datepicker-days-cell-over", this.regional = [], this.regional[""] = {
            closeText: "Done",
            prevText: "Prev",
            nextText: "Next",
            currentText: "Today",
            monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
            monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
            dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
            dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
            dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
            weekHeader: "Wk",
            dateFormat: "mm/dd/yy",
            firstDay: 0,
            isRTL: !1,
            showMonthAfterYear: !1,
            yearSuffix: ""
        }, this._defaults = {
            showOn: "focus",
            showAnim: "fadeIn",
            showOptions: {},
            defaultDate: null,
            appendText: "",
            buttonText: "...",
            buttonImage: "",
            buttonImageOnly: !1,
            hideIfNoPrevNext: !1,
            navigationAsDateFormat: !1,
            gotoCurrent: !1,
            changeMonth: !1,
            changeYear: !1,
            yearRange: "c-10:c+10",
            showOtherMonths: !1,
            selectOtherMonths: !1,
            showWeek: !1,
            calculateWeek: this.iso8601Week,
            shortYearCutoff: "+10",
            minDate: null,
            maxDate: null,
            duration: "fast",
            beforeShowDay: null,
            beforeShow: null,
            onSelect: null,
            onChangeMonthYear: null,
            onClose: null,
            numberOfMonths: 1,
            showCurrentAtPos: 0,
            stepMonths: 1,
            stepBigMonths: 12,
            altField: "",
            altFormat: "",
            constrainInput: !0,
            showButtonPanel: !1,
            autoSize: !1,
            disabled: !1
        }, $.extend(this._defaults, this.regional[""]), this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))
    }

    function bindHover(e) {
        var t = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
        return e.delegate(t, "mouseout", function () {
            $(this).removeClass("ui-state-hover"), -1 != this.className.indexOf("ui-datepicker-prev") && $(this).removeClass("ui-datepicker-prev-hover"), -1 != this.className.indexOf("ui-datepicker-next") && $(this).removeClass("ui-datepicker-next-hover")
        }).delegate(t, "mouseover", function () {
            $.datepicker._isDisabledDatepicker(instActive.inline ? e.parent()[0] : instActive.input[0]) || ($(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"), $(this).addClass("ui-state-hover"), -1 != this.className.indexOf("ui-datepicker-prev") && $(this).addClass("ui-datepicker-prev-hover"), -1 != this.className.indexOf("ui-datepicker-next") && $(this).addClass("ui-datepicker-next-hover"))
        })
    }

    function extendRemove(e, t) {
        $.extend(e, t);
        for (var n in t)(null == t[n] || t[n] == undefined) && (e[n] = t[n]);
        return e
    }
    $.extend($.ui, {
        datepicker: {
            version: "1.9.2"
        }
    });
    var PROP_NAME = "datepicker",
        dpuuid = (new Date).getTime(),
        instActive;
    $.extend(Datepicker.prototype, {
        markerClassName: "hasDatepicker",
        maxRows: 4,
        log: function () {
            this.debug && console.log.apply("", arguments)
        },
        _widgetDatepicker: function () {
            return this.dpDiv
        },
        setDefaults: function (e) {
            return extendRemove(this._defaults, e || {}), this
        },
        _attachDatepicker: function (target, settings) {
            var inlineSettings = null;
            for (var attrName in this._defaults) {
                var attrValue = target.getAttribute("date:" + attrName);
                if (attrValue) {
                    inlineSettings = inlineSettings || {};
                    try {
                        inlineSettings[attrName] = eval(attrValue)
                    } catch (err) {
                        inlineSettings[attrName] = attrValue
                    }
                }
            }
            var nodeName = target.nodeName.toLowerCase(),
                inline = "div" == nodeName || "span" == nodeName;
            target.id || (this.uuid += 1, target.id = "dp" + this.uuid);
            var inst = this._newInst($(target), inline);
            inst.settings = $.extend({}, settings || {}, inlineSettings || {}), "input" == nodeName ? this._connectDatepicker(target, inst) : inline && this._inlineDatepicker(target, inst)
        },
        _newInst: function (e, t) {
            var n = e[0].id.replace(/([^A-Za-z0-9_-])/g, "\\\\$1");
            return {
                id: n,
                input: e,
                selectedDay: 0,
                selectedMonth: 0,
                selectedYear: 0,
                drawMonth: 0,
                drawYear: 0,
                inline: t,
                dpDiv: t ? bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')) : this.dpDiv
            }
        },
        _connectDatepicker: function (e, t) {
            var n = $(e);
            t.append = $([]), t.trigger = $([]), n.hasClass(this.markerClassName) || (this._attachments(n, t), n.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker", function (e, n, r) {
                t.settings[n] = r
            }).bind("getData.datepicker", function (e, n) {
                return this._get(t, n)
            }), this._autoSize(t), $.data(e, PROP_NAME, t), t.settings.disabled && this._disableDatepicker(e))
        },
        _attachments: function (e, t) {
            var n = this._get(t, "appendText"),
                r = this._get(t, "isRTL");
            t.append && t.append.remove(), n && (t.append = $('<span class="' + this._appendClass + '">' + n + "</span>"), e[r ? "before" : "after"](t.append)), e.unbind("focus", this._showDatepicker), t.trigger && t.trigger.remove();
            var i = this._get(t, "showOn");
            if (("focus" == i || "both" == i) && e.focus(this._showDatepicker), "button" == i || "both" == i) {
                var s = this._get(t, "buttonText"),
                    o = this._get(t, "buttonImage");
                t.trigger = $(this._get(t, "buttonImageOnly") ? $("<img/>").addClass(this._triggerClass).attr({
                    src: o,
                    alt: s,
                    title: s
                }) : $('<button type="button"></button>').addClass(this._triggerClass).html("" == o ? s : $("<img/>").attr({
                    src: o,
                    alt: s,
                    title: s
                }))), e[r ? "before" : "after"](t.trigger), t.trigger.click(function () {
                    return $.datepicker._datepickerShowing && $.datepicker._lastInput == e[0] ? $.datepicker._hideDatepicker() : $.datepicker._datepickerShowing && $.datepicker._lastInput != e[0] ? ($.datepicker._hideDatepicker(), $.datepicker._showDatepicker(e[0])) : $.datepicker._showDatepicker(e[0]), !1
                })
            }
        },
        _autoSize: function (e) {
            if (this._get(e, "autoSize") && !e.inline) {
                var t = new Date(2009, 11, 20),
                    n = this._get(e, "dateFormat");
                if (n.match(/[DM]/)) {
                    var r = function (e) {
                        for (var t = 0, n = 0, r = 0; e.length > r; r++) e[r].length > t && (t = e[r].length, n = r);
                        return n
                    };
                    t.setMonth(r(this._get(e, n.match(/MM/) ? "monthNames" : "monthNamesShort"))), t.setDate(r(this._get(e, n.match(/DD/) ? "dayNames" : "dayNamesShort")) + 20 - t.getDay())
                }
                e.input.attr("size", this._formatDate(e, t).length)
            }
        },
        _inlineDatepicker: function (e, t) {
            var n = $(e);
            n.hasClass(this.markerClassName) || (n.addClass(this.markerClassName).append(t.dpDiv).bind("setData.datepicker", function (e, n, r) {
                t.settings[n] = r
            }).bind("getData.datepicker", function (e, n) {
                return this._get(t, n)
            }), $.data(e, PROP_NAME, t), this._setDate(t, this._getDefaultDate(t), !0), this._updateDatepicker(t), this._updateAlternate(t), t.settings.disabled && this._disableDatepicker(e), t.dpDiv.css("display", "block"))
        },
        _dialogDatepicker: function (e, t, n, r, i) {
            var s = this._dialogInst;
            if (!s) {
                this.uuid += 1;
                var o = "dp" + this.uuid;
                this._dialogInput = $('<input type="text" id="' + o + '" style="position: absolute; top: -100px; width: 0px;"/>'), this._dialogInput.keydown(this._doKeyDown), $("body").append(this._dialogInput), s = this._dialogInst = this._newInst(this._dialogInput, !1), s.settings = {}, $.data(this._dialogInput[0], PROP_NAME, s)
            }
            if (extendRemove(s.settings, r || {}), t = t && t.constructor == Date ? this._formatDate(s, t) : t, this._dialogInput.val(t), this._pos = i ? i.length ? i : [i.pageX, i.pageY] : null, !this._pos) {
                var u = document.documentElement.clientWidth,
                    a = document.documentElement.clientHeight,
                    f = document.documentElement.scrollLeft || document.body.scrollLeft,
                    l = document.documentElement.scrollTop || document.body.scrollTop;
                this._pos = [u / 2 - 100 + f, a / 2 - 150 + l]
            }
            return this._dialogInput.css("left", this._pos[0] + 20 + "px").css("top", this._pos[1] + "px"), s.settings.onSelect = n, this._inDialog = !0, this.dpDiv.addClass(this._dialogClass), this._showDatepicker(this._dialogInput[0]), $.blockUI && $.blockUI(this.dpDiv), $.data(this._dialogInput[0], PROP_NAME, s), this
        },
        _destroyDatepicker: function (e) {
            var t = $(e),
                n = $.data(e, PROP_NAME);
            if (t.hasClass(this.markerClassName)) {
                var r = e.nodeName.toLowerCase();
                $.removeData(e, PROP_NAME), "input" == r ? (n.append.remove(), n.trigger.remove(), t.removeClass(this.markerClassName).unbind("focus", this._showDatepicker).unbind("keydown", this._doKeyDown).unbind("keypress", this._doKeyPress).unbind("keyup", this._doKeyUp)) : ("div" == r || "span" == r) && t.removeClass(this.markerClassName).empty()
            }
        },
        _enableDatepicker: function (e) {
            var t = $(e),
                n = $.data(e, PROP_NAME);
            if (t.hasClass(this.markerClassName)) {
                var r = e.nodeName.toLowerCase();
                if ("input" == r) e.disabled = !1, n.trigger.filter("button").each(function () {
                    this.disabled = !1
                }).end().filter("img").css({
                    opacity: "1.0",
                    cursor: ""
                });
                else if ("div" == r || "span" == r) {
                    var i = t.children("." + this._inlineClass);
                    i.children().removeClass("ui-state-disabled"), i.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled", !1)
                }
                this._disabledInputs = $.map(this._disabledInputs, function (t) {
                    return t == e ? null : t
                })
            }
        },
        _disableDatepicker: function (e) {
            var t = $(e),
                n = $.data(e, PROP_NAME);
            if (t.hasClass(this.markerClassName)) {
                var r = e.nodeName.toLowerCase();
                if ("input" == r) e.disabled = !0, n.trigger.filter("button").each(function () {
                    this.disabled = !0
                }).end().filter("img").css({
                    opacity: "0.5",
                    cursor: "default"
                });
                else if ("div" == r || "span" == r) {
                    var i = t.children("." + this._inlineClass);
                    i.children().addClass("ui-state-disabled"), i.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled", !0)
                }
                this._disabledInputs = $.map(this._disabledInputs, function (t) {
                    return t == e ? null : t
                }), this._disabledInputs[this._disabledInputs.length] = e
            }
        },
        _isDisabledDatepicker: function (e) {
            if (!e) return !1;
            for (var t = 0; this._disabledInputs.length > t; t++)
                if (this._disabledInputs[t] == e) return !0;
            return !1
        },
        _getInst: function (e) {
            try {
                return $.data(e, PROP_NAME)
            } catch (t) {
                throw "Missing instance data for this datepicker"
            }
        },
        _optionDatepicker: function (e, t, n) {
            var r = this._getInst(e);
            if (2 == arguments.length && "string" == typeof t) return "defaults" == t ? $.extend({}, $.datepicker._defaults) : r ? "all" == t ? $.extend({}, r.settings) : this._get(r, t) : null;
            var i = t || {};
            if ("string" == typeof t && (i = {}, i[t] = n), r) {
                this._curInst == r && this._hideDatepicker();
                var s = this._getDateDatepicker(e, !0),
                    o = this._getMinMaxDate(r, "min"),
                    u = this._getMinMaxDate(r, "max");
                extendRemove(r.settings, i), null !== o && i.dateFormat !== undefined && i.minDate === undefined && (r.settings.minDate = this._formatDate(r, o)), null !== u && i.dateFormat !== undefined && i.maxDate === undefined && (r.settings.maxDate = this._formatDate(r, u)), this._attachments($(e), r), this._autoSize(r), this._setDate(r, s), this._updateAlternate(r), this._updateDatepicker(r)
            }
        },
        _changeDatepicker: function (e, t, n) {
            this._optionDatepicker(e, t, n)
        },
        _refreshDatepicker: function (e) {
            var t = this._getInst(e);
            t && this._updateDatepicker(t)
        },
        _setDateDatepicker: function (e, t) {
            var n = this._getInst(e);
            n && (this._setDate(n, t), this._updateDatepicker(n), this._updateAlternate(n))
        },
        _getDateDatepicker: function (e, t) {
            var n = this._getInst(e);
            return n && !n.inline && this._setDateFromField(n, t), n ? this._getDate(n) : null
        },
        _doKeyDown: function (e) {
            var t = $.datepicker._getInst(e.target),
                n = !0,
                r = t.dpDiv.is(".ui-datepicker-rtl");
            if (t._keyEvent = !0, $.datepicker._datepickerShowing) switch (e.keyCode) {
            case 9:
                $.datepicker._hideDatepicker(), n = !1;
                break;
            case 13:
                var i = $("td." + $.datepicker._dayOverClass + ":not(." + $.datepicker._currentClass + ")", t.dpDiv);
                i[0] && $.datepicker._selectDay(e.target, t.selectedMonth, t.selectedYear, i[0]);
                var s = $.datepicker._get(t, "onSelect");
                if (s) {
                    var o = $.datepicker._formatDate(t);
                    s.apply(t.input ? t.input[0] : null, [o, t])
                } else $.datepicker._hideDatepicker();
                return !1;
            case 27:
                $.datepicker._hideDatepicker();
                break;
            case 33:
                $.datepicker._adjustDate(e.target, e.ctrlKey ? -$.datepicker._get(t, "stepBigMonths") : -$.datepicker._get(t, "stepMonths"), "M");
                break;
            case 34:
                $.datepicker._adjustDate(e.target, e.ctrlKey ? +$.datepicker._get(t, "stepBigMonths") : +$.datepicker._get(t, "stepMonths"), "M");
                break;
            case 35:
                (e.ctrlKey || e.metaKey) && $.datepicker._clearDate(e.target), n = e.ctrlKey || e.metaKey;
                break;
            case 36:
                (e.ctrlKey || e.metaKey) && $.datepicker._gotoToday(e.target), n = e.ctrlKey || e.metaKey;
                break;
            case 37:
                (e.ctrlKey || e.metaKey) && $.datepicker._adjustDate(e.target, r ? 1 : -1, "D"), n = e.ctrlKey || e.metaKey, e.originalEvent.altKey && $.datepicker._adjustDate(e.target, e.ctrlKey ? -$.datepicker._get(t, "stepBigMonths") : -$.datepicker._get(t, "stepMonths"), "M");
                break;
            case 38:
                (e.ctrlKey || e.metaKey) && $.datepicker._adjustDate(e.target, -7, "D"), n = e.ctrlKey || e.metaKey;
                break;
            case 39:
                (e.ctrlKey || e.metaKey) && $.datepicker._adjustDate(e.target, r ? -1 : 1, "D"), n = e.ctrlKey || e.metaKey, e.originalEvent.altKey && $.datepicker._adjustDate(e.target, e.ctrlKey ? +$.datepicker._get(t, "stepBigMonths") : +$.datepicker._get(t, "stepMonths"), "M");
                break;
            case 40:
                (e.ctrlKey || e.metaKey) && $.datepicker._adjustDate(e.target, 7, "D"), n = e.ctrlKey || e.metaKey;
                break;
            default:
                n = !1
            } else 36 == e.keyCode && e.ctrlKey ? $.datepicker._showDatepicker(this) : n = !1;
            n && (e.preventDefault(), e.stopPropagation())
        },
        _doKeyPress: function (e) {
            var t = $.datepicker._getInst(e.target);
            if ($.datepicker._get(t, "constrainInput")) {
                var n = $.datepicker._possibleChars($.datepicker._get(t, "dateFormat")),
                    r = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode);
                return e.ctrlKey || e.metaKey || " " > r || !n || n.indexOf(r) > -1
            }
        },
        _doKeyUp: function (e) {
            var t = $.datepicker._getInst(e.target);
            if (t.input.val() != t.lastVal) try {
                var n = $.datepicker.parseDate($.datepicker._get(t, "dateFormat"), t.input ? t.input.val() : null, $.datepicker._getFormatConfig(t));
                n && ($.datepicker._setDateFromField(t), $.datepicker._updateAlternate(t), $.datepicker._updateDatepicker(t))
            } catch (r) {
                $.datepicker.log(r)
            }
            return !0
        },
        _showDatepicker: function (e) {
            if (e = e.target || e, "input" != e.nodeName.toLowerCase() && (e = $("input", e.parentNode)[0]), !$.datepicker._isDisabledDatepicker(e) && $.datepicker._lastInput != e) {
                var t = $.datepicker._getInst(e);
                $.datepicker._curInst && $.datepicker._curInst != t && ($.datepicker._curInst.dpDiv.stop(!0, !0), t && $.datepicker._datepickerShowing && $.datepicker._hideDatepicker($.datepicker._curInst.input[0]));
                var n = $.datepicker._get(t, "beforeShow"),
                    r = n ? n.apply(e, [e, t]) : {};
                if (r !== !1) {
                    extendRemove(t.settings, r), t.lastVal = null, $.datepicker._lastInput = e, $.datepicker._setDateFromField(t), $.datepicker._inDialog && (e.value = ""), $.datepicker._pos || ($.datepicker._pos = $.datepicker._findPos(e), $.datepicker._pos[1] += e.offsetHeight);
                    var i = !1;
                    $(e).parents().each(function () {
                        return i |= "fixed" == $(this).css("position"), !i
                    });
                    var s = {
                        left: $.datepicker._pos[0],
                        top: $.datepicker._pos[1]
                    };
                    if ($.datepicker._pos = null, t.dpDiv.empty(), t.dpDiv.css({
                        position: "absolute",
                        display: "block",
                        top: "-1000px"
                    }), $.datepicker._updateDatepicker(t), s = $.datepicker._checkOffset(t, s, i), t.dpDiv.css({
                        position: $.datepicker._inDialog && $.blockUI ? "static" : i ? "fixed" : "absolute",
                        display: "none",
                        left: s.left + "px",
                        top: s.top + "px"
                    }), !t.inline) {
                        var o = $.datepicker._get(t, "showAnim"),
                            u = $.datepicker._get(t, "duration"),
                            a = function () {
                                var e = t.dpDiv.find("iframe.ui-datepicker-cover");
                                if (e.length) {
                                    var n = $.datepicker._getBorders(t.dpDiv);
                                    e.css({
                                        left: -n[0],
                                        top: -n[1],
                                        width: t.dpDiv.outerWidth(),
                                        height: t.dpDiv.outerHeight()
                                    })
                                }
                            };
                        t.dpDiv.zIndex($(e).zIndex() + 1), $.datepicker._datepickerShowing = !0, $.effects && ($.effects.effect[o] || $.effects[o]) ? t.dpDiv.show(o, $.datepicker._get(t, "showOptions"), u, a) : t.dpDiv[o || "show"](o ? u : null, a), (!o || !u) && a(), t.input.is(":visible") && !t.input.is(":disabled") && t.input.focus(), $.datepicker._curInst = t
                    }
                }
            }
        },
        _updateDatepicker: function (e) {
            this.maxRows = 4;
            var t = $.datepicker._getBorders(e.dpDiv);
            instActive = e, e.dpDiv.empty().append(this._generateHTML(e)), this._attachHandlers(e);
            var n = e.dpDiv.find("iframe.ui-datepicker-cover");
            !n.length || n.css({
                left: -t[0],
                top: -t[1],
                width: e.dpDiv.outerWidth(),
                height: e.dpDiv.outerHeight()
            }), e.dpDiv.find("." + this._dayOverClass + " a").mouseover();
            var r = this._getNumberOfMonths(e),
                i = r[1],
                s = 17;
            if (e.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""), i > 1 && e.dpDiv.addClass("ui-datepicker-multi-" + i).css("width", s * i + "em"), e.dpDiv[(1 != r[0] || 1 != r[1] ? "add" : "remove") + "Class"]("ui-datepicker-multi"), e.dpDiv[(this._get(e, "isRTL") ? "add" : "remove") + "Class"]("ui-datepicker-rtl"), e == $.datepicker._curInst && $.datepicker._datepickerShowing && e.input && e.input.is(":visible") && !e.input.is(":disabled") && e.input[0] != document.activeElement && e.input.focus(), e.yearshtml) {
                var o = e.yearshtml;
                setTimeout(function () {
                    o === e.yearshtml && e.yearshtml && e.dpDiv.find("select.ui-datepicker-year:first").replaceWith(e.yearshtml), o = e.yearshtml = null
                }, 0)
            }
        },
        _getBorders: function (e) {
            var t = function (e) {
                return {
                    thin: 1,
                    medium: 2,
                    thick: 3
                }[e] || e
            };
            return [parseFloat(t(e.css("border-left-width"))), parseFloat(t(e.css("border-top-width")))]
        },
        _checkOffset: function (e, t, n) {
            var r = e.dpDiv.outerWidth(),
                i = e.dpDiv.outerHeight(),
                s = e.input ? e.input.outerWidth() : 0,
                o = e.input ? e.input.outerHeight() : 0,
                u = document.documentElement.clientWidth + (n ? 0 : $(document).scrollLeft()),
                a = document.documentElement.clientHeight + (n ? 0 : $(document).scrollTop());
            return t.left -= this._get(e, "isRTL") ? r - s : 0, t.left -= n && t.left == e.input.offset().left ? $(document).scrollLeft() : 0, t.top -= n && t.top == e.input.offset().top + o ? $(document).scrollTop() : 0, t.left -= Math.min(t.left, t.left + r > u && u > r ? Math.abs(t.left + r - u) : 0), t.top -= Math.min(t.top, t.top + i > a && a > i ? Math.abs(i + o) : 0), t
        },
        _findPos: function (e) {
            for (var t = this._getInst(e), n = this._get(t, "isRTL"); e && ("hidden" == e.type || 1 != e.nodeType || $.expr.filters.hidden(e));) e = e[n ? "previousSibling" : "nextSibling"];
            var r = $(e).offset();
            return [r.left, r.top]
        },
        _hideDatepicker: function (e) {
            var t = this._curInst;
            if (t && (!e || t == $.data(e, PROP_NAME)) && this._datepickerShowing) {
                var n = this._get(t, "showAnim"),
                    r = this._get(t, "duration"),
                    i = function () {
                        $.datepicker._tidyDialog(t)
                    };
                $.effects && ($.effects.effect[n] || $.effects[n]) ? t.dpDiv.hide(n, $.datepicker._get(t, "showOptions"), r, i) : t.dpDiv["slideDown" == n ? "slideUp" : "fadeIn" == n ? "fadeOut" : "hide"](n ? r : null, i), n || i(), this._datepickerShowing = !1;
                var s = this._get(t, "onClose");
                s && s.apply(t.input ? t.input[0] : null, [t.input ? t.input.val() : "", t]), this._lastInput = null, this._inDialog && (this._dialogInput.css({
                    position: "absolute",
                    left: "0",
                    top: "-100px"
                }), $.blockUI && ($.unblockUI(), $("body").append(this.dpDiv))), this._inDialog = !1
            }
        },
        _tidyDialog: function (e) {
            e.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")
        },
        _checkExternalClick: function (e) {
            if ($.datepicker._curInst) {
                var t = $(e.target),
                    n = $.datepicker._getInst(t[0]);
                (t[0].id != $.datepicker._mainDivId && 0 == t.parents("#" + $.datepicker._mainDivId).length && !t.hasClass($.datepicker.markerClassName) && !t.closest("." + $.datepicker._triggerClass).length && $.datepicker._datepickerShowing && (!$.datepicker._inDialog || !$.blockUI) || t.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != n) && $.datepicker._hideDatepicker()
            }
        },
        _adjustDate: function (e, t, n) {
            var r = $(e),
                i = this._getInst(r[0]);
            this._isDisabledDatepicker(r[0]) || (this._adjustInstDate(i, t + ("M" == n ? this._get(i, "showCurrentAtPos") : 0), n), this._updateDatepicker(i))
        },
        _gotoToday: function (e) {
            var t = $(e),
                n = this._getInst(t[0]);
            if (this._get(n, "gotoCurrent") && n.currentDay) n.selectedDay = n.currentDay, n.drawMonth = n.selectedMonth = n.currentMonth, n.drawYear = n.selectedYear = n.currentYear;
            else {
                var r = new Date;
                n.selectedDay = r.getDate(), n.drawMonth = n.selectedMonth = r.getMonth(), n.drawYear = n.selectedYear = r.getFullYear()
            }
            this._notifyChange(n), this._adjustDate(t)
        },
        _selectMonthYear: function (e, t, n) {
            var r = $(e),
                i = this._getInst(r[0]);
            i["selected" + ("M" == n ? "Month" : "Year")] = i["draw" + ("M" == n ? "Month" : "Year")] = parseInt(t.options[t.selectedIndex].value, 10), this._notifyChange(i), this._adjustDate(r)
        },
        _selectDay: function (e, t, n, r) {
            var i = $(e);
            if (!$(r).hasClass(this._unselectableClass) && !this._isDisabledDatepicker(i[0])) {
                var s = this._getInst(i[0]);
                s.selectedDay = s.currentDay = $("a", r).html(), s.selectedMonth = s.currentMonth = t, s.selectedYear = s.currentYear = n, this._selectDate(e, this._formatDate(s, s.currentDay, s.currentMonth, s.currentYear))
            }
        },
        _clearDate: function (e) {
            var t = $(e);
            this._getInst(t[0]), this._selectDate(t, "")
        },
        _selectDate: function (e, t) {
            var n = $(e),
                r = this._getInst(n[0]);
            t = null != t ? t : this._formatDate(r), r.input && r.input.val(t), this._updateAlternate(r);
            var i = this._get(r, "onSelect");
            i ? i.apply(r.input ? r.input[0] : null, [t, r]) : r.input && r.input.trigger("change"), r.inline ? this._updateDatepicker(r) : (this._hideDatepicker(), this._lastInput = r.input[0], "object" != typeof r.input[0] && r.input.focus(), this._lastInput = null)
        },
        _updateAlternate: function (e) {
            var t = this._get(e, "altField");
            if (t) {
                var n = this._get(e, "altFormat") || this._get(e, "dateFormat"),
                    r = this._getDate(e),
                    i = this.formatDate(n, r, this._getFormatConfig(e));
                $(t).each(function () {
                    $(this).val(i)
                })
            }
        },
        noWeekends: function (e) {
            var t = e.getDay();
            return [t > 0 && 6 > t, ""]
        },
        iso8601Week: function (e) {
            var t = new Date(e.getTime());
            t.setDate(t.getDate() + 4 - (t.getDay() || 7));
            var n = t.getTime();
            return t.setMonth(0), t.setDate(1), Math.floor(Math.round((n - t) / 864e5) / 7) + 1
        },
        parseDate: function (e, t, n) {
            if (null == e || null == t) throw "Invalid arguments";
            if (t = "object" == typeof t ? "" + t : t + "", "" == t) return null;
            var r = (n ? n.shortYearCutoff : null) || this._defaults.shortYearCutoff;
            r = "string" != typeof r ? r : (new Date).getFullYear() % 100 + parseInt(r, 10);
            for (var i = (n ? n.dayNamesShort : null) || this._defaults.dayNamesShort, s = (n ? n.dayNames : null) || this._defaults.dayNames, o = (n ? n.monthNamesShort : null) || this._defaults.monthNamesShort, u = (n ? n.monthNames : null) || this._defaults.monthNames, a = -1, f = -1, l = -1, c = -1, h = !1, p = function (t) {
                    var n = e.length > y + 1 && e.charAt(y + 1) == t;
                    return n && y++, n
                }, d = function (e) {
                    var n = p(e),
                        r = "@" == e ? 14 : "!" == e ? 20 : "y" == e && n ? 4 : "o" == e ? 3 : 2,
                        i = RegExp("^\\d{1," + r + "}"),
                        s = t.substring(g).match(i);
                    if (!s) throw "Missing number at position " + g;
                    return g += s[0].length, parseInt(s[0], 10)
                }, v = function (e, n, r) {
                    var i = $.map(p(e) ? r : n, function (e, t) {
                        return [[t, e]]
                    }).sort(function (e, t) {
                        return -(e[1].length - t[1].length)
                    }),
                        s = -1;
                    if ($.each(i, function (e, n) {
                        var r = n[1];
                        return t.substr(g, r.length).toLowerCase() == r.toLowerCase() ? (s = n[0], g += r.length, !1) : undefined
                    }), -1 != s) return s + 1;
                    throw "Unknown name at position " + g
                }, m = function () {
                    if (t.charAt(g) != e.charAt(y)) throw "Unexpected literal at position " + g;
                    g++
                }, g = 0, y = 0; e.length > y; y++)
                if (h) "'" != e.charAt(y) || p("'") ? m() : h = !1;
                else switch (e.charAt(y)) {
                case "d":
                    l = d("d");
                    break;
                case "D":
                    v("D", i, s);
                    break;
                case "o":
                    c = d("o");
                    break;
                case "m":
                    f = d("m");
                    break;
                case "M":
                    f = v("M", o, u);
                    break;
                case "y":
                    a = d("y");
                    break;
                case "@":
                    var b = new Date(d("@"));
                    a = b.getFullYear(), f = b.getMonth() + 1, l = b.getDate();
                    break;
                case "!":
                    var b = new Date((d("!") - this._ticksTo1970) / 1e4);
                    a = b.getFullYear(), f = b.getMonth() + 1, l = b.getDate();
                    break;
                case "'":
                    p("'") ? m() : h = !0;
                    break;
                default:
                    m()
                }
                if (t.length > g) {
                    var w = t.substr(g);
                    if (!/^\s+/.test(w)) throw "Extra/unparsed characters found in date: " + w
                }
            if (-1 == a ? a = (new Date).getFullYear() : 100 > a && (a += (new Date).getFullYear() - (new Date).getFullYear() % 100 + (r >= a ? 0 : -100)), c > -1)
                for (f = 1, l = c;;) {
                    var E = this._getDaysInMonth(a, f - 1);
                    if (E >= l) break;
                    f++, l -= E
                }
            var b = this._daylightSavingAdjust(new Date(a, f - 1, l));
            if (b.getFullYear() != a || b.getMonth() + 1 != f || b.getDate() != l) throw "Invalid date";
            return b
        },
        ATOM: "yy-mm-dd",
        COOKIE: "D, dd M yy",
        ISO_8601: "yy-mm-dd",
        RFC_822: "D, d M y",
        RFC_850: "DD, dd-M-y",
        RFC_1036: "D, d M y",
        RFC_1123: "D, d M yy",
        RFC_2822: "D, d M yy",
        RSS: "D, d M y",
        TICKS: "!",
        TIMESTAMP: "@",
        W3C: "yy-mm-dd",
        _ticksTo1970: 1e7 * 60 * 60 * 24 * (718685 + Math.floor(492.5) - Math.floor(19.7) + Math.floor(4.925)),
        formatDate: function (e, t, n) {
            if (!t) return "";
            var r = (n ? n.dayNamesShort : null) || this._defaults.dayNamesShort,
                i = (n ? n.dayNames : null) || this._defaults.dayNames,
                s = (n ? n.monthNamesShort : null) || this._defaults.monthNamesShort,
                o = (n ? n.monthNames : null) || this._defaults.monthNames,
                u = function (t) {
                    var n = e.length > h + 1 && e.charAt(h + 1) == t;
                    return n && h++, n
                }, a = function (e, t, n) {
                    var r = "" + t;
                    if (u(e))
                        for (; n > r.length;) r = "0" + r;
                    return r
                }, f = function (e, t, n, r) {
                    return u(e) ? r[t] : n[t]
                }, l = "",
                c = !1;
            if (t)
                for (var h = 0; e.length > h; h++)
                    if (c) "'" != e.charAt(h) || u("'") ? l += e.charAt(h) : c = !1;
                    else switch (e.charAt(h)) {
                    case "d":
                        l += a("d", t.getDate(), 2);
                        break;
                    case "D":
                        l += f("D", t.getDay(), r, i);
                        break;
                    case "o":
                        l += a("o", Math.round((new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime() - new Date(t.getFullYear(), 0, 0).getTime()) / 864e5), 3);
                        break;
                    case "m":
                        l += a("m", t.getMonth() + 1, 2);
                        break;
                    case "M":
                        l += f("M", t.getMonth(), s, o);
                        break;
                    case "y":
                        l += u("y") ? t.getFullYear() : (10 > t.getYear() % 100 ? "0" : "") + t.getYear() % 100;
                        break;
                    case "@":
                        l += t.getTime();
                        break;
                    case "!":
                        l += 1e4 * t.getTime() + this._ticksTo1970;
                        break;
                    case "'":
                        u("'") ? l += "'" : c = !0;
                        break;
                    default:
                        l += e.charAt(h)
                    }
                    return l
        },
        _possibleChars: function (e) {
            for (var t = "", n = !1, r = function (t) {
                    var n = e.length > i + 1 && e.charAt(i + 1) == t;
                    return n && i++, n
                }, i = 0; e.length > i; i++)
                if (n) "'" != e.charAt(i) || r("'") ? t += e.charAt(i) : n = !1;
                else switch (e.charAt(i)) {
                case "d":
                case "m":
                case "y":
                case "@":
                    t += "0123456789";
                    break;
                case "D":
                case "M":
                    return null;
                case "'":
                    r("'") ? t += "'" : n = !0;
                    break;
                default:
                    t += e.charAt(i)
                }
                return t
        },
        _get: function (e, t) {
            return e.settings[t] !== undefined ? e.settings[t] : this._defaults[t]
        },
        _setDateFromField: function (e, t) {
            if (e.input.val() != e.lastVal) {
                var i, s, n = this._get(e, "dateFormat"),
                    r = e.lastVal = e.input ? e.input.val() : null;
                i = s = this._getDefaultDate(e);
                var o = this._getFormatConfig(e);
                try {
                    i = this.parseDate(n, r, o) || s
                } catch (u) {
                    this.log(u), r = t ? "" : r
                }
                e.selectedDay = i.getDate(), e.drawMonth = e.selectedMonth = i.getMonth(), e.drawYear = e.selectedYear = i.getFullYear(), e.currentDay = r ? i.getDate() : 0, e.currentMonth = r ? i.getMonth() : 0, e.currentYear = r ? i.getFullYear() : 0, this._adjustInstDate(e)
            }
        },
        _getDefaultDate: function (e) {
            return this._restrictMinMax(e, this._determineDate(e, this._get(e, "defaultDate"), new Date))
        },
        _determineDate: function (e, t, n) {
            var r = function (e) {
                var t = new Date;
                return t.setDate(t.getDate() + e), t
            }, i = function (t) {
                    try {
                        return $.datepicker.parseDate($.datepicker._get(e, "dateFormat"), t, $.datepicker._getFormatConfig(e))
                    } catch (n) {}
                    for (var r = (t.toLowerCase().match(/^c/) ? $.datepicker._getDate(e) : null) || new Date, i = r.getFullYear(), s = r.getMonth(), o = r.getDate(), u = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, a = u.exec(t); a;) {
                        switch (a[2] || "d") {
                        case "d":
                        case "D":
                            o += parseInt(a[1], 10);
                            break;
                        case "w":
                        case "W":
                            o += 7 * parseInt(a[1], 10);
                            break;
                        case "m":
                        case "M":
                            s += parseInt(a[1], 10), o = Math.min(o, $.datepicker._getDaysInMonth(i, s));
                            break;
                        case "y":
                        case "Y":
                            i += parseInt(a[1], 10), o = Math.min(o, $.datepicker._getDaysInMonth(i, s))
                        }
                        a = u.exec(t)
                    }
                    return new Date(i, s, o)
                }, s = null == t || "" === t ? n : "string" == typeof t ? i(t) : "number" == typeof t ? isNaN(t) ? n : r(t) : new Date(t.getTime());
            return s = s && "Invalid Date" == "" + s ? n : s, s && (s.setHours(0), s.setMinutes(0), s.setSeconds(0), s.setMilliseconds(0)), this._daylightSavingAdjust(s)
        },
        _daylightSavingAdjust: function (e) {
            return e ? (e.setHours(e.getHours() > 12 ? e.getHours() + 2 : 0), e) : null
        },
        _setDate: function (e, t, n) {
            var r = !t,
                i = e.selectedMonth,
                s = e.selectedYear,
                o = this._restrictMinMax(e, this._determineDate(e, t, new Date));
            e.selectedDay = e.currentDay = o.getDate(), e.drawMonth = e.selectedMonth = e.currentMonth = o.getMonth(), e.drawYear = e.selectedYear = e.currentYear = o.getFullYear(), (i != e.selectedMonth || s != e.selectedYear) && !n && this._notifyChange(e), this._adjustInstDate(e), e.input && e.input.val(r ? "" : this._formatDate(e))
        },
        _getDate: function (e) {
            var t = !e.currentYear || e.input && "" == e.input.val() ? null : this._daylightSavingAdjust(new Date(e.currentYear, e.currentMonth, e.currentDay));
            return t
        },
        _attachHandlers: function (e) {
            var t = this._get(e, "stepMonths"),
                n = "#" + e.id.replace(/\\\\/g, "\\");
            e.dpDiv.find("[data-handler]").map(function () {
                var e = {
                    prev: function () {
                        window["DP_jQuery_" + dpuuid].datepicker._adjustDate(n, -t, "M")
                    },
                    next: function () {
                        window["DP_jQuery_" + dpuuid].datepicker._adjustDate(n, +t, "M")
                    },
                    hide: function () {
                        window["DP_jQuery_" + dpuuid].datepicker._hideDatepicker()
                    },
                    today: function () {
                        window["DP_jQuery_" + dpuuid].datepicker._gotoToday(n)
                    },
                    selectDay: function () {
                        return window["DP_jQuery_" + dpuuid].datepicker._selectDay(n, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this), !1
                    },
                    selectMonth: function () {
                        return window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(n, this, "M"), !1
                    },
                    selectYear: function () {
                        return window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(n, this, "Y"), !1
                    }
                };
                $(this).bind(this.getAttribute("data-event"), e[this.getAttribute("data-handler")])
            })
        },
        _generateHTML: function (e) {
            var t = new Date;
            t = this._daylightSavingAdjust(new Date(t.getFullYear(), t.getMonth(), t.getDate()));
            var n = this._get(e, "isRTL"),
                r = this._get(e, "showButtonPanel"),
                i = this._get(e, "hideIfNoPrevNext"),
                s = this._get(e, "navigationAsDateFormat"),
                o = this._getNumberOfMonths(e),
                u = this._get(e, "showCurrentAtPos"),
                a = this._get(e, "stepMonths"),
                f = 1 != o[0] || 1 != o[1],
                l = this._daylightSavingAdjust(e.currentDay ? new Date(e.currentYear, e.currentMonth, e.currentDay) : new Date(9999, 9, 9)),
                c = this._getMinMaxDate(e, "min"),
                h = this._getMinMaxDate(e, "max"),
                p = e.drawMonth - u,
                d = e.drawYear;
            if (0 > p && (p += 12, d--), h) {
                var v = this._daylightSavingAdjust(new Date(h.getFullYear(), h.getMonth() - o[0] * o[1] + 1, h.getDate()));
                for (v = c && c > v ? c : v; this._daylightSavingAdjust(new Date(d, p, 1)) > v;) p--, 0 > p && (p = 11, d--)
            }
            e.drawMonth = p, e.drawYear = d;
            var m = this._get(e, "prevText");
            m = s ? this.formatDate(m, this._daylightSavingAdjust(new Date(d, p - a, 1)), this._getFormatConfig(e)) : m;
            var g = this._canAdjustMonth(e, -1, d, p) ? '<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click" title="' + m + '"><span class="ui-icon ui-icon-circle-triangle-' + (n ? "e" : "w") + '">' + m + "</span></a>" : i ? "" : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="' + m + '"><span class="ui-icon ui-icon-circle-triangle-' + (n ? "e" : "w") + '">' + m + "</span></a>",
                y = this._get(e, "nextText");
            y = s ? this.formatDate(y, this._daylightSavingAdjust(new Date(d, p + a, 1)), this._getFormatConfig(e)) : y;
            var b = this._canAdjustMonth(e, 1, d, p) ? '<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click" title="' + y + '"><span class="ui-icon ui-icon-circle-triangle-' + (n ? "w" : "e") + '">' + y + "</span></a>" : i ? "" : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="' + y + '"><span class="ui-icon ui-icon-circle-triangle-' + (n ? "w" : "e") + '">' + y + "</span></a>",
                w = this._get(e, "currentText"),
                E = this._get(e, "gotoCurrent") && e.currentDay ? l : t;
            w = s ? this.formatDate(w, E, this._getFormatConfig(e)) : w;
            var S = e.inline ? "" : '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" data-handler="hide" data-event="click">' + this._get(e, "closeText") + "</button>",
                x = r ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (n ? S : "") + (this._isInRange(e, E) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" data-handler="today" data-event="click">' + w + "</button>" : "") + (n ? "" : S) + "</div>" : "",
                T = parseInt(this._get(e, "firstDay"), 10);
            T = isNaN(T) ? 0 : T;
            for (var N = this._get(e, "showWeek"), C = this._get(e, "dayNames"), L = (this._get(e, "dayNamesShort"), this._get(e, "dayNamesMin")), A = this._get(e, "monthNames"), O = this._get(e, "monthNamesShort"), M = this._get(e, "beforeShowDay"), _ = this._get(e, "showOtherMonths"), D = this._get(e, "selectOtherMonths"), H = (this._get(e, "calculateWeek") || this.iso8601Week, this._getDefaultDate(e)), B = "", j = 0; o[0] > j; j++) {
                var F = "";
                this.maxRows = 4;
                for (var I = 0; o[1] > I; I++) {
                    var q = this._daylightSavingAdjust(new Date(d, p, e.selectedDay)),
                        R = " ui-corner-all",
                        U = "";
                    if (f) {
                        if (U += '<div class="ui-datepicker-group', o[1] > 1) switch (I) {
                        case 0:
                            U += " ui-datepicker-group-first", R = " ui-corner-" + (n ? "right" : "left");
                            break;
                        case o[1] - 1:
                            U += " ui-datepicker-group-last", R = " ui-corner-" + (n ? "left" : "right");
                            break;
                        default:
                            U += " ui-datepicker-group-middle", R = ""
                        }
                        U += '">'
                    }
                    U += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + R + '">' + (/all|left/.test(R) && 0 == j ? n ? b : g : "") + (/all|right/.test(R) && 0 == j ? n ? g : b : "") + this._generateMonthYearHeader(e, p, d, c, h, j > 0 || I > 0, A, O) + '</div><table class="ui-datepicker-calendar"><thead>' + "<tr>";
                    for (var z = N ? '<th class="ui-datepicker-week-col">' + this._get(e, "weekHeader") + "</th>" : "", W = 0; 7 > W; W++) {
                        var X = (W + T) % 7;
                        z += "<th" + ((W + T + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : "") + ">" + '<span title="' + C[X] + '">' + L[X] + "</span></th>"
                    }
                    U += z + "</tr></thead><tbody>";
                    var V = this._getDaysInMonth(d, p);
                    d == e.selectedYear && p == e.selectedMonth && (e.selectedDay = Math.min(e.selectedDay, V));
                    var J = (this._getFirstDayOfMonth(d, p) - T + 7) % 7,
                        K = Math.ceil((J + V) / 7),
                        Q = f ? this.maxRows > K ? this.maxRows : K : K;
                    this.maxRows = Q;
                    for (var G = this._daylightSavingAdjust(new Date(d, p, 1 - J)), Y = 0; Q > Y; Y++) {
                        U += "<tr>";
                        for (var Z = N ? '<td class="ui-datepicker-week-col">' + this._get(e, "calculateWeek")(G) + "</td>" : "", W = 0; 7 > W; W++) {
                            var et = M ? M.apply(e.input ? e.input[0] : null, [G]) : [!0, ""],
                                tt = G.getMonth() != p,
                                nt = tt && !D || !et[0] || c && c > G || h && G > h;
                            Z += '<td class="' + ((W + T + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + (tt ? " ui-datepicker-other-month" : "") + (G.getTime() == q.getTime() && p == e.selectedMonth && e._keyEvent || H.getTime() == G.getTime() && H.getTime() == q.getTime() ? " " + this._dayOverClass : "") + (nt ? " " + this._unselectableClass + " ui-state-disabled" : "") + (tt && !_ ? "" : " " + et[1] + (G.getTime() == l.getTime() ? " " + this._currentClass : "") + (G.getTime() == t.getTime() ? " ui-datepicker-today" : "")) + '"' + (tt && !_ || !et[2] ? "" : ' title="' + et[2] + '"') + (nt ? "" : ' data-handler="selectDay" data-event="click" data-month="' + G.getMonth() + '" data-year="' + G.getFullYear() + '"') + ">" + (tt && !_ ? "&#xa0;" : nt ? '<span class="ui-state-default">' + G.getDate() + "</span>" : '<a class="ui-state-default' + (G.getTime() == t.getTime() ? " ui-state-highlight" : "") + (G.getTime() == l.getTime() ? " ui-state-active" : "") + (tt ? " ui-priority-secondary" : "") + '" href="#">' + G.getDate() + "</a>") + "</td>", G.setDate(G.getDate() + 1), G = this._daylightSavingAdjust(G)
                        }
                        U += Z + "</tr>"
                    }
                    p++, p > 11 && (p = 0, d++), U += "</tbody></table>" + (f ? "</div>" + (o[0] > 0 && I == o[1] - 1 ? '<div class="ui-datepicker-row-break"></div>' : "") : ""), F += U
                }
                B += F
            }
            return B += x + ($.ui.ie6 && !e.inline ? '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : ""), e._keyEvent = !1, B
        },
        _generateMonthYearHeader: function (e, t, n, r, i, s, o, u) {
            var a = this._get(e, "changeMonth"),
                f = this._get(e, "changeYear"),
                l = this._get(e, "showMonthAfterYear"),
                c = '<div class="ui-datepicker-title">',
                h = "";
            if (s || !a) h += '<span class="ui-datepicker-month">' + o[t] + "</span>";
            else {
                var p = r && r.getFullYear() == n,
                    d = i && i.getFullYear() == n;
                h += '<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">';
                for (var v = 0; 12 > v; v++)(!p || v >= r.getMonth()) && (!d || i.getMonth() >= v) && (h += '<option value="' + v + '"' + (v == t ? ' selected="selected"' : "") + ">" + u[v] + "</option>");
                h += "</select>"
            } if (l || (c += h + (!s && a && f ? "" : "&#xa0;")), !e.yearshtml)
                if (e.yearshtml = "", s || !f) c += '<span class="ui-datepicker-year">' + n + "</span>";
                else {
                    var m = this._get(e, "yearRange").split(":"),
                        g = (new Date).getFullYear(),
                        y = function (e) {
                            var t = e.match(/c[+-].*/) ? n + parseInt(e.substring(1), 10) : e.match(/[+-].*/) ? g + parseInt(e, 10) : parseInt(e, 10);
                            return isNaN(t) ? g : t
                        }, b = y(m[0]),
                        w = Math.max(b, y(m[1] || ""));
                    for (b = r ? Math.max(b, r.getFullYear()) : b, w = i ? Math.min(w, i.getFullYear()) : w, e.yearshtml += '<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">'; w >= b; b++) e.yearshtml += '<option value="' + b + '"' + (b == n ? ' selected="selected"' : "") + ">" + b + "</option>";
                    e.yearshtml += "</select>", c += e.yearshtml, e.yearshtml = null
                }
            return c += this._get(e, "yearSuffix"), l && (c += (!s && a && f ? "" : "&#xa0;") + h), c += "</div>"
        },
        _adjustInstDate: function (e, t, n) {
            var r = e.drawYear + ("Y" == n ? t : 0),
                i = e.drawMonth + ("M" == n ? t : 0),
                s = Math.min(e.selectedDay, this._getDaysInMonth(r, i)) + ("D" == n ? t : 0),
                o = this._restrictMinMax(e, this._daylightSavingAdjust(new Date(r, i, s)));
            e.selectedDay = o.getDate(), e.drawMonth = e.selectedMonth = o.getMonth(), e.drawYear = e.selectedYear = o.getFullYear(), ("M" == n || "Y" == n) && this._notifyChange(e)
        },
        _restrictMinMax: function (e, t) {
            var n = this._getMinMaxDate(e, "min"),
                r = this._getMinMaxDate(e, "max"),
                i = n && n > t ? n : t;
            return i = r && i > r ? r : i
        },
        _notifyChange: function (e) {
            var t = this._get(e, "onChangeMonthYear");
            t && t.apply(e.input ? e.input[0] : null, [e.selectedYear, e.selectedMonth + 1, e])
        },
        _getNumberOfMonths: function (e) {
            var t = this._get(e, "numberOfMonths");
            return null == t ? [1, 1] : "number" == typeof t ? [1, t] : t
        },
        _getMinMaxDate: function (e, t) {
            return this._determineDate(e, this._get(e, t + "Date"), null)
        },
        _getDaysInMonth: function (e, t) {
            return 32 - this._daylightSavingAdjust(new Date(e, t, 32)).getDate()
        },
        _getFirstDayOfMonth: function (e, t) {
            return new Date(e, t, 1).getDay()
        },
        _canAdjustMonth: function (e, t, n, r) {
            var i = this._getNumberOfMonths(e),
                s = this._daylightSavingAdjust(new Date(n, r + (0 > t ? t : i[0] * i[1]), 1));
            return 0 > t && s.setDate(this._getDaysInMonth(s.getFullYear(), s.getMonth())), this._isInRange(e, s)
        },
        _isInRange: function (e, t) {
            var n = this._getMinMaxDate(e, "min"),
                r = this._getMinMaxDate(e, "max");
            return (!n || t.getTime() >= n.getTime()) && (!r || t.getTime() <= r.getTime())
        },
        _getFormatConfig: function (e) {
            var t = this._get(e, "shortYearCutoff");
            return t = "string" != typeof t ? t : (new Date).getFullYear() % 100 + parseInt(t, 10), {
                shortYearCutoff: t,
                dayNamesShort: this._get(e, "dayNamesShort"),
                dayNames: this._get(e, "dayNames"),
                monthNamesShort: this._get(e, "monthNamesShort"),
                monthNames: this._get(e, "monthNames")
            }
        },
        _formatDate: function (e, t, n, r) {
            t || (e.currentDay = e.selectedDay, e.currentMonth = e.selectedMonth, e.currentYear = e.selectedYear);
            var i = t ? "object" == typeof t ? t : this._daylightSavingAdjust(new Date(r, n, t)) : this._daylightSavingAdjust(new Date(e.currentYear, e.currentMonth, e.currentDay));
            return this.formatDate(this._get(e, "dateFormat"), i, this._getFormatConfig(e))
        }
    }), $.fn.datepicker = function (e) {
        if (!this.length) return this;
        $.datepicker.initialized || ($(document).mousedown($.datepicker._checkExternalClick).find(document.body).append($.datepicker.dpDiv), $.datepicker.initialized = !0);
        var t = Array.prototype.slice.call(arguments, 1);
        return "string" != typeof e || "isDisabled" != e && "getDate" != e && "widget" != e ? "option" == e && 2 == arguments.length && "string" == typeof arguments[1] ? $.datepicker["_" + e + "Datepicker"].apply($.datepicker, [this[0]].concat(t)) : this.each(function () {
            "string" == typeof e ? $.datepicker["_" + e + "Datepicker"].apply($.datepicker, [this].concat(t)) : $.datepicker._attachDatepicker(this, e)
        }) : $.datepicker["_" + e + "Datepicker"].apply($.datepicker, [this[0]].concat(t))
    }, $.datepicker = new Datepicker, $.datepicker.initialized = !1, $.datepicker.uuid = (new Date).getTime(), $.datepicker.version = "1.9.2", window["DP_jQuery_" + dpuuid] = $
}(jQuery),
function (e) {
    var n = !1;
    e.widget("ui.menu", {
        version: "1.9.2",
        defaultElement: "<ul>",
        delay: 300,
        options: {
            icons: {
                submenu: "ui-icon-carat-1-e"
            },
            menus: "ul",
            position: {
                my: "left top",
                at: "right top"
            },
            role: "menu",
            blur: null,
            focus: null,
            select: null
        },
        _create: function () {
            this.activeMenu = this.element, this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content ui-corner-all").toggleClass("ui-menu-icons", !! this.element.find(".ui-icon").length).attr({
                role: this.options.role,
                tabIndex: 0
            }).bind("click" + this.eventNamespace, e.proxy(function (e) {
                this.options.disabled && e.preventDefault()
            }, this)), this.options.disabled && this.element.addClass("ui-state-disabled").attr("aria-disabled", "true"), this._on({
                "mousedown .ui-menu-item > a": function (e) {
                    e.preventDefault()
                },
                "click .ui-state-disabled > a": function (e) {
                    e.preventDefault()
                },
                "click .ui-menu-item:has(a)": function (t) {
                    var r = e(t.target).closest(".ui-menu-item");
                    !n && r.not(".ui-state-disabled").length && (n = !0, this.select(t), r.has(".ui-menu").length ? this.expand(t) : this.element.is(":focus") || (this.element.trigger("focus", [!0]), this.active && 1 === this.active.parents(".ui-menu").length && clearTimeout(this.timer)))
                },
                "mouseenter .ui-menu-item": function (t) {
                    var n = e(t.currentTarget);
                    n.siblings().children(".ui-state-active").removeClass("ui-state-active"), this.focus(t, n)
                },
                mouseleave: "collapseAll",
                "mouseleave .ui-menu": "collapseAll",
                focus: function (e, t) {
                    var n = this.active || this.element.children(".ui-menu-item").eq(0);
                    t || this.focus(e, n)
                },
                blur: function (t) {
                    this._delay(function () {
                        e.contains(this.element[0], this.document[0].activeElement) || this.collapseAll(t)
                    })
                },
                keydown: "_keydown"
            }), this.refresh(), this._on(this.document, {
                click: function (t) {
                    e(t.target).closest(".ui-menu").length || this.collapseAll(t), n = !1
                }
            })
        },
        _destroy: function () {
            this.element.removeAttr("aria-activedescendant").find(".ui-menu").andSelf().removeClass("ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(), this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").children("a").removeUniqueId().removeClass("ui-corner-all ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function () {
                var t = e(this);
                t.data("ui-menu-submenu-carat") && t.remove()
            }), this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")
        },
        _keydown: function (t) {
            function a(e) {
                return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&")
            }
            var n, r, i, s, o, u = !0;
            switch (t.keyCode) {
            case e.ui.keyCode.PAGE_UP:
                this.previousPage(t);
                break;
            case e.ui.keyCode.PAGE_DOWN:
                this.nextPage(t);
                break;
            case e.ui.keyCode.HOME:
                this._move("first", "first", t);
                break;
            case e.ui.keyCode.END:
                this._move("last", "last", t);
                break;
            case e.ui.keyCode.UP:
                this.previous(t);
                break;
            case e.ui.keyCode.DOWN:
                this.next(t);
                break;
            case e.ui.keyCode.LEFT:
                this.collapse(t);
                break;
            case e.ui.keyCode.RIGHT:
                this.active && !this.active.is(".ui-state-disabled") && this.expand(t);
                break;
            case e.ui.keyCode.ENTER:
            case e.ui.keyCode.SPACE:
                this._activate(t);
                break;
            case e.ui.keyCode.ESCAPE:
                this.collapse(t);
                break;
            default:
                u = !1, r = this.previousFilter || "", i = String.fromCharCode(t.keyCode), s = !1, clearTimeout(this.filterTimer), i === r ? s = !0 : i = r + i, o = RegExp("^" + a(i), "i"), n = this.activeMenu.children(".ui-menu-item").filter(function () {
                    return o.test(e(this).children("a").text())
                }), n = s && -1 !== n.index(this.active.next()) ? this.active.nextAll(".ui-menu-item") : n, n.length || (i = String.fromCharCode(t.keyCode), o = RegExp("^" + a(i), "i"), n = this.activeMenu.children(".ui-menu-item").filter(function () {
                    return o.test(e(this).children("a").text())
                })), n.length ? (this.focus(t, n), n.length > 1 ? (this.previousFilter = i, this.filterTimer = this._delay(function () {
                    delete this.previousFilter
                }, 1e3)) : delete this.previousFilter) : delete this.previousFilter
            }
            u && t.preventDefault()
        },
        _activate: function (e) {
            this.active.is(".ui-state-disabled") || (this.active.children("a[aria-haspopup='true']").length ? this.expand(e) : this.select(e))
        },
        refresh: function () {
            var t, n = this.options.icons.submenu,
                r = this.element.find(this.options.menus);
            r.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-corner-all").hide().attr({
                role: this.options.role,
                "aria-hidden": "true",
                "aria-expanded": "false"
            }).each(function () {
                var t = e(this),
                    r = t.prev("a"),
                    i = e("<span>").addClass("ui-menu-icon ui-icon " + n).data("ui-menu-submenu-carat", !0);
                r.attr("aria-haspopup", "true").prepend(i), t.attr("aria-labelledby", r.attr("id"))
            }), t = r.add(this.element), t.children(":not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role", "presentation").children("a").uniqueId().addClass("ui-corner-all").attr({
                tabIndex: -1,
                role: this._itemRole()
            }), t.children(":not(.ui-menu-item)").each(function () {
                var t = e(this);
                /[^\-�붴�s]/.test(t.text()) || t.addClass("ui-widget-content ui-menu-divider")
            }), t.children(".ui-state-disabled").attr("aria-disabled", "true"), this.active && !e.contains(this.element[0], this.active[0]) && this.blur()
        },
        _itemRole: function () {
            return {
                menu: "menuitem",
                listbox: "option"
            }[this.options.role]
        },
        focus: function (e, t) {
            var n, r;
            this.blur(e, e && "focus" === e.type), this._scrollIntoView(t), this.active = t.first(), r = this.active.children("a").addClass("ui-state-focus"), this.options.role && this.element.attr("aria-activedescendant", r.attr("id")), this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active"), e && "keydown" === e.type ? this._close() : this.timer = this._delay(function () {
                this._close()
            }, this.delay), n = t.children(".ui-menu"), n.length && /^mouse/.test(e.type) && this._startOpening(n), this.activeMenu = t.parent(), this._trigger("focus", e, {
                item: t
            })
        },
        _scrollIntoView: function (t) {
            var n, r, i, s, o, u;
            this._hasScroll() && (n = parseFloat(e.css(this.activeMenu[0], "borderTopWidth")) || 0, r = parseFloat(e.css(this.activeMenu[0], "paddingTop")) || 0, i = t.offset().top - this.activeMenu.offset().top - n - r, s = this.activeMenu.scrollTop(), o = this.activeMenu.height(), u = t.height(), 0 > i ? this.activeMenu.scrollTop(s + i) : i + u > o && this.activeMenu.scrollTop(s + i - o + u))
        },
        blur: function (e, t) {
            t || clearTimeout(this.timer), this.active && (this.active.children("a").removeClass("ui-state-focus"), this.active = null, this._trigger("blur", e, {
                item: this.active
            }))
        },
        _startOpening: function (e) {
            clearTimeout(this.timer), "true" === e.attr("aria-hidden") && (this.timer = this._delay(function () {
                this._close(), this._open(e)
            }, this.delay))
        },
        _open: function (t) {
            var n = e.extend({
                of: this.active
            }, this.options.position);
            clearTimeout(this.timer), this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden", "true"), t.show().removeAttr("aria-hidden").attr("aria-expanded", "true").position(n)
        },
        collapseAll: function (t, n) {
            clearTimeout(this.timer), this.timer = this._delay(function () {
                var r = n ? this.element : e(t && t.target).closest(this.element.find(".ui-menu"));
                r.length || (r = this.element), this._close(r), this.blur(t), this.activeMenu = r
            }, this.delay)
        },
        _close: function (e) {
            e || (e = this.active ? this.active.parent() : this.element), e.find(".ui-menu").hide().attr("aria-hidden", "true").attr("aria-expanded", "false").end().find("a.ui-state-active").removeClass("ui-state-active")
        },
        collapse: function (e) {
            var t = this.active && this.active.parent().closest(".ui-menu-item", this.element);
            t && t.length && (this._close(), this.focus(e, t))
        },
        expand: function (e) {
            var t = this.active && this.active.children(".ui-menu ").children(".ui-menu-item").first();
            t && t.length && (this._open(t.parent()), this._delay(function () {
                this.focus(e, t)
            }))
        },
        next: function (e) {
            this._move("next", "first", e)
        },
        previous: function (e) {
            this._move("prev", "last", e)
        },
        isFirstItem: function () {
            return this.active && !this.active.prevAll(".ui-menu-item").length
        },
        isLastItem: function () {
            return this.active && !this.active.nextAll(".ui-menu-item").length
        },
        _move: function (e, t, n) {
            var r;
            this.active && (r = "first" === e || "last" === e ? this.active["first" === e ? "prevAll" : "nextAll"](".ui-menu-item").eq(-1) : this.active[e + "All"](".ui-menu-item").eq(0)), r && r.length && this.active || (r = this.activeMenu.children(".ui-menu-item")[t]()), this.focus(n, r)
        },
        nextPage: function (t) {
            var n, r, i;
            return this.active ? (this.isLastItem() || (this._hasScroll() ? (r = this.active.offset().top, i = this.element.height(), this.active.nextAll(".ui-menu-item").each(function () {
                return n = e(this), 0 > n.offset().top - r - i
            }), this.focus(t, n)) : this.focus(t, this.activeMenu.children(".ui-menu-item")[this.active ? "last" : "first"]())), void 0) : (this.next(t), void 0)
        },
        previousPage: function (t) {
            var n, r, i;
            return this.active ? (this.isFirstItem() || (this._hasScroll() ? (r = this.active.offset().top, i = this.element.height(), this.active.prevAll(".ui-menu-item").each(function () {
                return n = e(this), n.offset().top - r + i > 0
            }), this.focus(t, n)) : this.focus(t, this.activeMenu.children(".ui-menu-item").first())), void 0) : (this.next(t), void 0)
        },
        _hasScroll: function () {
            return this.element.outerHeight() < this.element.prop("scrollHeight")
        },
        select: function (t) {
            this.active = this.active || e(t.target).closest(".ui-menu-item");
            var n = {
                item: this.active
            };
            this.active.has(".ui-menu").length || this.collapseAll(t, !0), this._trigger("select", t, n)
        }
    })
}(jQuery);
var nd = nd || {};
nd.events = nd.events || {}, nd.events.initEventsHandlers = function () {
    var handleSubmitEvent = function (event) {
        $(event.currentTarget), $(".actions .btn").hide(), $("#spinner_bottom").show();
        var handleSubmitEventSuccess = function (data) {
            if (data.errors) {
                $(".actions .btn").show(), $("#spinner_bottom").hide();
                for (var field in data.errors) {
                    var error_field = $("#id_" + field + "_error");
                    error_field.html(data.errors[field]), error_field.show()
                }
            } else if (data.success && data.event_id) {
                var eventUrl = "/events/" + data.event_id;
                window.location.href = eventUrl
            }
        }, handleSubmitEventError = function () {
                var error_field = $("#id_title_error"),
                    html = "I'm sorry, theres been an error.  If you've ";
                html += "uploaded a document please check the field type.<br/>", error_field.html(html), error_field.show()
            };
        $(".error").hide(), $("#create_event_form").ajaxSubmit({
            dataType: "json",
            success: handleSubmitEventSuccess,
            error: handleSubmitEventError
        })
    };
    if ($('a[data-action="delete-event-modal"]').click(function () {
        var $this = $(this),
            modalBody = $this.data("modal-body") || "#default_delete_event_body";
        modalBody = $(modalBody), modalBody.siblings('[data-class*="delete-event-body"]').hide(), modalBody.show();
        var deleteModal = $("#delete_event_modal");
        deleteModal.modal(), deleteModal.find("#submit_delete_event").off("click").click(function () {
            $.getJSON("/ajax/delete_event/", {
                event_id: $this.data("event-id")
            }, function (data) {
                data.success && 1 == data.success && data.event_id && setTimeout(function () {
                    deleteModal.modal("hide"), window.location.href = "/events/"
                }, 2e3)
            })
        })
    }), $('[data-action="prepare-submission"]').on("click", handleSubmitEvent), $("#id_start_time_desktop").datepicker({
        dateFormat: "yy-mm-dd"
    }), $("#id_end_time_desktop").datepicker({
        dateFormat: "yy-mm-dd"
    }), $("#id_end_time_mobile").val($("#id_end_time_desktop").val()), "" != $("#id_start_time_desktop").val()) $("#id_start_time_mobile").val($("#id_start_time_desktop").val());
    else {
        var currentDate = new Date,
            day = currentDate.getDate();
        day = 10 > day ? "0" + day : day;
        var month = currentDate.getMonth() + 1;
        month = 10 > month ? "0" + month : month;
        var year = currentDate.getFullYear();
        $("#id_start_time_mobile").val(year + "-" + month + "-" + day)
    }
    $("#id_start_time_desktop").change(function () {
        $("#id_start_time_mobile").val($(this).val())
    }), $("#id_start_time_mobile").change(function () {
        $("#id_start_time_desktop").val($(this).val())
    }), $("#id_end_time_desktop").change(function () {
        $("#id_end_time_mobile").val($(this).val())
    }), $("#id_end_time_mobile").change(function () {
        $("#id_end_time_desktop").val($(this).val())
    })
};